1 | #! perl # OPTIONAL |
1 | #! perl # optional |
2 | |
2 | |
3 | # optional plug-in to speed up worldmap rendering by dynamically |
3 | # optional plug-in to speed up worldmap rendering by dynamically |
4 | # generating it out of an image |
4 | # generating it out of an image |
5 | # - saves loading time (less data to read) |
5 | # - saves loading time (less data to read) |
6 | # - saves temporary space (only overlay stuff needs to be saved) |
6 | # - saves temporary space (only overlay stuff needs to be saved) |
… | |
… | |
119 | $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 0; |
119 | $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 0; |
120 | $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 999; |
120 | $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 999; |
121 | $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 999; |
121 | $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 999; |
122 | $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 0; |
122 | $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 0; |
123 | |
123 | |
124 | $self->{load_path} = sprintf "%s/world-overlay/world_%03d_%03d.map", $cf::MAPDIR, $x, $y |
124 | my $overlay = sprintf "%s/world/world_%03d_%03d.map", $cf::MAPDIR, $x, $y; |
125 | if $x >= 100 && $x <= 129 && $y >= 100 && $y <= 129; |
125 | |
|
|
126 | $self->{load_path} = $overlay |
|
|
127 | unless Coro::AIO::aio_stat $overlay; |
|
|
128 | |
|
|
129 | $self->{need_create_treasure} = 1; |
126 | |
130 | |
127 | 1 |
131 | 1 |
128 | } |
132 | } |
129 | |
133 | |
130 | sub fill { |
134 | sub fill { |
… | |
… | |
141 | $self->SUPER::load; |
145 | $self->SUPER::load; |
142 | } else { |
146 | } else { |
143 | $self->alloc; |
147 | $self->alloc; |
144 | $self->fill; |
148 | $self->fill; |
145 | $self->in_memory (cf::MAP_IN_MEMORY); |
149 | $self->in_memory (cf::MAP_IN_MEMORY); |
|
|
150 | $self->activate; |
146 | } |
151 | } |
147 | } |
152 | } |
148 | |
153 | |
149 | sub post_load { |
154 | sub post_load { |
150 | my ($self) = @_; |
155 | my ($self) = @_; |
151 | |
156 | |
|
|
157 | { |
152 | my $guard = cf::lock_acquire "ext::world_gridmap"; |
158 | my $guard = cf::lock_acquire "ext::world_gridmap"; |
153 | |
159 | |
154 | my ($x, $y) = $self->wxwy; |
160 | my ($x, $y) = $self->wxwy; |
155 | |
161 | |
156 | if ($x >= 100 && $x <= 129 && $y >= 100 && $y <= 129) { |
162 | if ($x >= 100 && $x <= 129 && $y >= 100 && $y <= 129) { |
157 | my $stride = $WORLD->{grid_w} * $WORLD->{tile_w}; |
163 | my $stride = $WORLD->{grid_w} * $WORLD->{tile_w}; |
158 | my $top = ($y - 100) * $WORLD->{tile_h} * $stride |
164 | my $top = ($y - 100) * $WORLD->{tile_h} * $stride |
159 | + ($x - 100) * $WORLD->{tile_w}; |
165 | + ($x - 100) * $WORLD->{tile_w}; |
160 | |
166 | |
161 | $self->add_underlay ($WORLD->{arc_data}, $top, $stride, $WORLD->{arc_plt}); |
167 | $self->add_underlay ($WORLD->{arc_data}, $top, $stride, $WORLD->{arc_plt}); |
162 | $self->set_regiondata ($WORLD->{reg_data}, $top, $stride, $WORLD->{reg_plt}); |
168 | $self->set_regiondata ($WORLD->{reg_data}, $top, $stride, $WORLD->{reg_plt}); |
163 | |
169 | |
164 | } else { |
170 | } else { |
165 | $self->fill; |
171 | $self->fill; |
|
|
172 | } |
166 | } |
173 | } |
|
|
174 | |
|
|
175 | $self->create_region_treasure |
|
|
176 | if delete $self->{need_create_treasure}; |
167 | } |
177 | } |
168 | |
178 | |
169 | 1 |
179 | 1 |
170 | |
180 | |