Skip to content

Commit

Permalink
engine: client now clears out chunks on disconnect. prevents weirdnes…
Browse files Browse the repository at this point in the history
…s on reconnect.
  • Loading branch information
Robin Redeker authored and zpmorgan committed Jul 19, 2011
1 parent ca6bef5 commit 7edc4c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Games/VoxEngine/Client.pm
Expand Up @@ -331,6 +331,7 @@ sub disconnected {
my ($self) = @_;
delete $self->{srv};
$self->{front}->msg ("Disconnected from server!");
$self->{front}->clear_chunks;
$self->{recon} = AE::timer 5, 0, sub { $self->reconnect; };
vox_log (info => "disconnected from server");
}
Expand Down
11 changes: 11 additions & 0 deletions lib/Games/VoxEngine/Client/Frontend.pm
Expand Up @@ -275,6 +275,17 @@ sub set_ambient_light {
$self->all_chunks_dirty;
}

sub clear_chunks {
my ($self) = @_;

for (keys %{$self->{compiled_chunks}}) {
my $p = world_id2pos ($_);
$self->free_compiled_chunk (@$p);
}

$self->{dirty_chunks} = {};
}

sub all_chunks_dirty {
my ($self) = @_;
for my $id (keys %{$self->{compiled_chunks}}) {
Expand Down

0 comments on commit 7edc4c4

Please sign in to comment.