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.13 by root, Tue Feb 13 19:25:44 2007 UTC vs.
Revision 1.20 by root, Sat Apr 14 07:22:59 2007 UTC

67} 67}
68 68
69sub load_gridmap($) { 69sub load_gridmap($) {
70 my ($path) = @_; 70 my ($path) = @_;
71 71
72 if (! -e "/tmp/xxxx.gridmap") { 72# if (! -e "/tmp/xxxx.gridmap") {
73 0 < aio_load "$path/gridmap.meta", my $map 73 0 < aio_load "$path/gridmap.meta", my $map
74 or cf::cleanup "$path/gridmap.meta: $!\n"; 74 or cf::cleanup "$path/gridmap.meta: $!\n";
75 75
76 $map = cf::from_json $map; 76 $map = cf::from_json $map;
77 77
79 or cf::cleanup "$path/gridmap.meta: empty gridmap?"; 79 or cf::cleanup "$path/gridmap.meta: empty gridmap?";
80 80
81 ($map->{arc_data}, $map->{arc_plt}) = load_indexed "$path/gridmap.arch", $size; 81 ($map->{arc_data}, $map->{arc_plt}) = load_indexed "$path/gridmap.arch", $size;
82 ($map->{reg_data}, $map->{reg_plt}) = load_indexed "$path/gridmap.regn", $size; 82 ($map->{reg_data}, $map->{reg_plt}) = load_indexed "$path/gridmap.regn", $size;
83 83
84 Storable::nstore $map, "/tmp/xxxx.gridmap";#d# 84# Storable::nstore $map, "/tmp/xxxx.gridmap" if 0;#d#
85 85
86 $map 86 $map
87 } else { 87# } else {
88 Storable::retrieve "/tmp/xxxx.gridmap"; 88# Storable::retrieve "/tmp/xxxx.gridmap";
89 } 89# }
90} 90}
91 91
92# this is contorted, but likely the correct way to acquire the lock :) 92# this is contorted, but likely the correct way to acquire the lock :)
93cf::sync_job { 93cf::sync_job {
94 my $guard = cf::lock_acquire "ext::world_gridmap"; 94 my $guard = cf::lock_acquire "ext::world_gridmap";
118 $self->height ($WORLD->{tile_h}); 118 $self->height ($WORLD->{tile_h});
119 119
120 $self->name ("'The World' at +$x+$y"); 120 $self->name ("'The World' at +$x+$y");
121 $self->msg ("worldmap dynamically created by map-world extension"); 121 $self->msg ("worldmap dynamically created by map-world extension");
122 $self->outdoor (1); 122 $self->outdoor (1);
123 $self->default_region (undef); 123 $self->default_region (cf::region::find "wilderness");
124 124
125 $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 0; 125 $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 0;
126 $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 999; 126 $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 999;
127 $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 999; 127 $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 999;
128 $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 0; 128 $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 0;
129 129
130 $self->{load_path} = sprintf "%s/%s/world-overlay/world_%03d_%03d", cf::datadir, cf::mapdir, $x, $y 130 $self->{load_path} = sprintf "%s/%s/world-overlay/world_%03d_%03d.map", cf::datadir, cf::mapdir, $x, $y
131 if $x >= 100 && $x <= 129 && $y >= 100 && $y <= 129; 131 if $x >= 100 && $x <= 129 && $y >= 100 && $y <= 129;
132 132
133 1 133 1
134} 134}
135 135
136sub fill { 136sub fill {
137 my ($self) = @_; 137 my ($self) = @_;
138 138
139 for my $X (0 .. $WORLD->{tile_w} - 1) { 139 $self->add_underlay ("\x00" x ($WORLD->{tile_w} * $WORLD->{tile_h}), 0, $WORLD->{tile_w}, $WORLD->{arc_plt});
140 Coro::cede;
141 for my $Y (0 .. $WORLD->{tile_h} - 1) {
142 my $ob = cf::object::new "deep_sea";
143 $ob->flag (cf::FLAG_NO_MAP_SAVE, 1);
144 $self->insert ($ob, $X, $Y, undef, cf::INS_ABOVE_FLOOR_ONLY);
145 }
146 }
147 $self->set_object_flag (cf::FLAG_NO_MAP_SAVE, 1);
148 $self->default_region (cf::region::find "panthalassia"); 140 $self->default_region (cf::region::find $WORLD->{reg_plt}[0]);
149} 141}
150 142
151sub load { 143sub load {
152 my ($self) = @_; 144 my ($self) = @_;
153 145
170 if ($x >= 100 && $x <= 129 && $y >= 100 && $y <= 129) { 162 if ($x >= 100 && $x <= 129 && $y >= 100 && $y <= 129) {
171 my $stride = $WORLD->{grid_w} * $WORLD->{tile_w}; 163 my $stride = $WORLD->{grid_w} * $WORLD->{tile_w};
172 my $top = ($y - 100) * $WORLD->{tile_h} * $stride 164 my $top = ($y - 100) * $WORLD->{tile_h} * $stride
173 + ($x - 100) * $WORLD->{tile_w}; 165 + ($x - 100) * $WORLD->{tile_w};
174 166
175 my $reg; 167 $self->add_underlay ($WORLD->{arc_data}, $top, $stride, $WORLD->{arc_plt});
168 $self->set_regiondata ($WORLD->{reg_data}, $top, $stride, $WORLD->{reg_plt});
176 169
177 for my $Y (0 .. $WORLD->{tile_h} - 1) {
178 Coro::cede;
179 my $row = substr $WORLD->{arc_data}, $top + $Y * $stride, $WORLD->{tile_w};
180 $reg .= substr $WORLD->{reg_data}, $top + $Y * $stride, $WORLD->{tile_w};
181 for my $X (0 .. $WORLD->{tile_w} - 1) {
182 next if grep $_->flag (cf::FLAG_IS_FLOOR), $self->at ($X, $Y);
183 my $ob = cf::object::new $WORLD->{arc_plt}[ord substr $row, $X];
184 $ob->flag (cf::FLAG_NO_MAP_SAVE, 1);
185 $self->insert ($ob, $X, $Y, undef, cf::INS_ABOVE_FLOOR_ONLY);
186 }
187 }
188
189 $self->set_regiondata ($reg, $WORLD->{reg_plt});
190 } else { 170 } else {
191 $self->fill; 171 $self->fill;
192 } 172 }
193} 173}
194 174

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines