ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.53 by root, Mon Jul 3 22:32:52 2006 UTC vs.
Revision 1.57 by root, Tue Jul 11 15:30:23 2006 UTC

84 print $fh "$ts ", @a, "\n"; 84 print $fh "$ts ", @a, "\n";
85 $fh->flush; 85 $fh->flush;
86} 86}
87 87
88sub _stat_numdiff { 88sub _stat_numdiff {
89 my ($self, $old, $new) = @_; 89 my ($self, $name, $old, $new) = @_;
90 90
91 my $diff = $new - $old; 91 my $diff = $new - $old;
92 $diff > 0 ? "+$diff" : $diff 92
93 $diff = 0.01 * int $diff * 100;
94
95 0.1 >= abs $diff ? ()
96 : $diff < 0 ? "$name$diff" : "$name+$diff"
93} 97}
94 98
95sub _stat_skillmaskdiff { 99sub _stat_skillmaskdiff {
96 my ($self, $old, $new) = @_; 100 my ($self, $name, $old, $new) = @_;
97 101
98 my $diff = $old ^ $new; 102 my $diff = $old ^ $new
103 or return;
99 104
100 my @diff = map 105 my @diff = map
101 { 106 {
102 $diff & $_ 107 $diff & $_
103 ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_}) 108 ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_})
156 if (my $diff = $stats->{+CS_STAT_EXP64} - $prev->{+CS_STAT_EXP64}) { 161 if (my $diff = $stats->{+CS_STAT_EXP64} - $prev->{+CS_STAT_EXP64}) {
157 $self->{statusbox}->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5); 162 $self->{statusbox}->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5);
158 } 163 }
159 164
160 if ( 165 if (
161 my @diffs = map { 166 my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange
162 $stats->{$_->[0]} != $prev->{$_->[0]}
163 ? $_->[2] . $_->[1]->($self, $prev->{$_->[0]}, $stats->{$_->[0]}) : ();
164 }
165 @statchange
166 ) { 167 ) {
167 my $msg = "<b>stat change</b>: " . (join " ", @diffs); 168 my $msg = "<b>stat change</b>: " . (join " ", @diffs);
168 $self->{statusbox}->add ($msg, group => $msg, fg => [0.8, 1, 0.2, 1], timeout => 10); 169 $self->{statusbox}->add ($msg, group => $msg, fg => [0.8, 1, 0.2, 1], timeout => 10);
169 } 170 }
170 } 171 }
421} 422}
422 423
423sub face_update { 424sub face_update {
424 my ($self, $facenum, $face) = @_; 425 my ($self, $facenum, $face) = @_;
425 426
426 $self->{tilecache}->put ($face->{id} => $face->{image}); #TODO: try to avoid duplicate writes 427 $self->{tilecache}->put ($face->{id} => $face->{image})
428 if $self->{tilecache}->get ($face->{id}) ne $face->{image};
427 429
428 $self->set_texture ($face->{id} => delete $face->{image}); 430 $self->set_texture ($face->{id} => delete $face->{image});
429} 431}
430 432
431sub set_texture { 433sub set_texture {
650 652
651sub update_containers { 653sub update_containers {
652 my ($self) = @_; 654 my ($self) = @_;
653 655
654 $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub { 656 $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub {
655 for my $tag (keys %{ delete $self->{update_container} }) { 657 my $todo = delete $self->{update_container}
658 or return;
659
660 for my $tag (keys %$todo) {
656 if ($tag == 0) { 661 if ($tag == 0) {
657 update_floorbox; 662 update_floorbox;
658 $::INVR->set_items ($self->{container}{0}) 663 $::INVR->set_items ($self->{container}{0})
659 if $tag == $self->{open_container}; 664 if $tag == $self->{open_container};
660 } elsif ($tag == $self->{player}{tag}) { 665 } elsif ($tag == $self->{player}{tag}) {
704 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item); 709 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item);
705 710
706 } else { 711 } else {
707 $self->{update_container}{$item->{container}}++; 712 $self->{update_container}{$item->{container}}++;
708 $self->update_containers; 713 $self->update_containers;
709# if ($item->{container} == 0) {
710# update_floorbox;
711# update_container (0);
712# } elsif ($item->{container} == $self->{player}{tag}) {
713# $::INV->set_items ($self->{container}{$item->{container}})
714# }
715 } 714 }
716} 715}
717 716
718sub player_update { 717sub player_update {
719 my ($self, $player) = @_; 718 my ($self, $player) = @_;
921sub destroy { 920sub destroy {
922 my ($self) = @_; 921 my ($self) = @_;
923 922
924 #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1 923 #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1
925 924
925 $self->{conn}->send ("ext npc_dialog_end $self->{token}") if $self->{token};
926 delete $self->{conn}{npc_dialog}; 926 delete $self->{conn}{npc_dialog};
927 $self->{conn}->disconnect_ext ($self->{token}); 927 $self->{conn}->disconnect_ext ($self->{token});
928 928
929 $self->SUPER::destroy; 929 $self->SUPER::destroy;
930} 930}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines