… | |
… | |
402 | |
402 | |
403 | $self->{map}->clear; |
403 | $self->{map}->clear; |
404 | delete $self->{map_widget}{magicmap}; |
404 | delete $self->{map_widget}{magicmap}; |
405 | } |
405 | } |
406 | |
406 | |
|
|
407 | sub bg_fetch { |
|
|
408 | my ($self) = @_; |
|
|
409 | |
|
|
410 | my $id; |
|
|
411 | |
|
|
412 | do { |
|
|
413 | $id = pop @{$self->{bg_fetch}} |
|
|
414 | or return; |
|
|
415 | } while $self->{texture}[$id]; |
|
|
416 | |
|
|
417 | CFPlus::DB::get tilecache => $id, sub { |
|
|
418 | my ($data) = @_; |
|
|
419 | |
|
|
420 | $self->set_texture ($id => $data) |
|
|
421 | if defined $data; |
|
|
422 | |
|
|
423 | $self->bg_fetch; |
|
|
424 | }; |
|
|
425 | } |
407 | |
426 | |
408 | sub load_map($$$) { |
427 | sub load_map($$$) { |
409 | my ($self, $hash, $x, $y) = @_; |
428 | my ($self, $hash, $x, $y) = @_; |
410 | |
429 | |
411 | CFPlus::DB::get $self->{mapcache} => $hash, sub { |
430 | CFPlus::DB::get $self->{mapcache} => $hash, sub { |
412 | my ($data) = @_; |
431 | my ($data) = @_; |
413 | |
432 | |
414 | if (defined $data) { |
433 | if (defined $data) { |
415 | $data = Compress::LZF::decompress $data; |
434 | $data = Compress::LZF::decompress $data; |
416 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
435 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
417 | for my $id ($self->{map}->set_rect ($x, $y, $data)) { |
|
|
418 | CFPlus::DB::get tilecache => $id, sub { |
|
|
419 | my ($data) = @_; |
|
|
420 | |
436 | |
421 | $self->set_texture ($id => $data) |
437 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
422 | if defined $data; |
438 | push @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); |
423 | }; |
439 | $self->bg_fetch unless $inprogress; |
424 | } |
|
|
425 | } |
440 | } |
426 | }; |
441 | }; |
427 | } |
442 | } |
428 | |
443 | |
429 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
444 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |