… | |
… | |
78 | |
78 | |
79 | Coro::Storable::thaw $map |
79 | Coro::Storable::thaw $map |
80 | } |
80 | } |
81 | |
81 | |
82 | sub reload() { |
82 | sub reload() { |
83 | $WORLD = load_gridmap sprintf "%s/%s/%s", cf::datadir, cf::mapdir, "world"; |
83 | $WORLD = load_gridmap "$MAPDIR/world"; |
84 | warn "worldmap gridmap loaded."; |
84 | warn "worldmap gridmap loaded."; |
85 | } |
85 | } |
86 | |
86 | |
87 | # this is contorted, but likely the correct way to acquire the lock :) |
87 | # this is contorted, but likely the correct way to acquire the lock :) |
88 | cf::sync_job { |
88 | cf::sync_job { |
89 | my $guard = cf::lock_acquire "ext::world_gridmap"; |
89 | my $guard = cf::lock_acquire "ext::world_gridmap"; |
90 | cf::async_ext { |
90 | cf::async_ext { |
91 | reload; |
91 | reload; |
92 | undef $guard; |
92 | undef $guard; |
93 | } |
93 | }; |
94 | }; |
94 | }; |
95 | |
95 | |
96 | cf::map->register (qr{^/world/world_(\d\d\d)_(\d\d\d)$}, 100); |
96 | cf::map->register (qr{^/world/world_(\d\d\d)_(\d\d\d)$}, 100); |
97 | |
97 | |
98 | sub wxwy { |
98 | sub wxwy { |
… | |
… | |
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/%s/world-overlay/world_%03d_%03d.map", cf::datadir, cf::mapdir, $x, $y |
124 | $self->{load_path} = sprintf "%s/world-overlay/world_%03d_%03d.map", $cf::MAPDIR, $x, $y |
125 | if $x >= 100 && $x <= 129 && $y >= 100 && $y <= 129; |
125 | if $x >= 100 && $x <= 129 && $y >= 100 && $y <= 129; |
|
|
126 | |
|
|
127 | $self->{need_create_treasure} = 1; |
126 | |
128 | |
127 | 1 |
129 | 1 |
128 | } |
130 | } |
129 | |
131 | |
130 | sub fill { |
132 | sub fill { |
… | |
… | |
162 | $self->set_regiondata ($WORLD->{reg_data}, $top, $stride, $WORLD->{reg_plt}); |
164 | $self->set_regiondata ($WORLD->{reg_data}, $top, $stride, $WORLD->{reg_plt}); |
163 | |
165 | |
164 | } else { |
166 | } else { |
165 | $self->fill; |
167 | $self->fill; |
166 | } |
168 | } |
|
|
169 | |
|
|
170 | $self->create_region_treasure |
|
|
171 | if delete $self->{need_create_treasure}; |
167 | } |
172 | } |
168 | |
173 | |
169 | 1 |
174 | 1 |
170 | |
175 | |