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.197 by root, Tue May 20 02:47:21 2008 UTC vs.
Revision 1.202 by root, Tue Sep 9 10:27:26 2008 UTC

11use DC::Pod; 11use DC::Pod;
12use DC::Macro; 12use DC::Macro;
13use DC::Item; 13use DC::Item;
14 14
15use base 'Deliantra::Protocol::Base'; 15use base 'Deliantra::Protocol::Base';
16
17our $TEX_DIALOGUE = new_from_resource DC::Texture
18 "dialogue.png", minify => 1, mipmap => 1;
19
20our $TEX_NOFACE = new_from_resource DC::Texture
21 "noface.png", minify => 1, mipmap => 1;
16 22
17sub new { 23sub new {
18 my ($class, %arg) = @_; 24 my ($class, %arg) = @_;
19 25
20 my $self = $class->SUPER::new (%arg, 26 my $self = $class->SUPER::new (%arg,
75 81
76 $self->{map_widget}->add_command (@$_) 82 $self->{map_widget}->add_command (@$_)
77 for @cmd_help; 83 for @cmd_help;
78 84
79 { 85 {
80 $self->{dialogue} = my $tex = new_from_file DC::Texture 86 $self->{dialogue} = my $tex = $TEX_DIALOGUE;
81 DC::find_rcfile "dialogue.png", minify => 1, mipmap => 1;
82 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 87 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
83 } 88 }
84 89
85 { 90 {
86 $self->{noface} = my $tex = new_from_file DC::Texture 91 $self->{noface} = my $tex = $TEX_NOFACE;
87 DC::find_rcfile "noface.png", minify => 1, mipmap => 1;
88 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 92 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
89 } 93 }
90 94
91 $self->{open_container} = 0; 95 $self->{open_container} = 0;
92 96
637} 641}
638 642
639sub map_scroll { 643sub map_scroll {
640 my ($self, $dx, $dy) = @_; 644 my ($self, $dx, $dy) = @_;
641 645
642 $self->{map}->scroll ($dx, $dy); 646 $self->{map_widget}->scroll ($dx, $dy);
643} 647}
644 648
645sub feed_map1a { 649sub feed_map1a {
646 my ($self, $data) = @_; 650 my ($self, $data) = @_;
647 651
694 my $data = $self->{map}->get_rect ($x, $y, $w, $h); 698 my $data = $self->{map}->get_rect ($x, $y, $w, $h);
695 699
696 if ($data ne $$rdata) { 700 if ($data ne $$rdata) {
697 $map_info->[1] = \$data; 701 $map_info->[1] = \$data;
698 my $cdata = Compress::LZF::compress $data; 702 my $cdata = Compress::LZF::compress $data;
699 warn "db_put $hash $x $y ", length $data, " > ", length $cdata;
700 DC::DB::put $self->{mapcache} => $hash => $cdata, sub { }; 703 DC::DB::put $self->{mapcache} => $hash => $cdata, sub { };
701 } 704 }
702 } 705 }
703} 706}
704 707
742 745
743 my $map_info = $self->{map_cache}{$hash} = [$hash, \"", $x, $y, $w, $h]; 746 my $map_info = $self->{map_cache}{$hash} = [$hash, \"", $x, $y, $w, $h];
744 747
745 my $cb = sub { 748 my $cb = sub {
746 $map_info->[1] = \$_[0]; 749 $map_info->[1] = \$_[0];
747
748 return if 2505 == length $_[0];#d#
749 warn "map_cache $hash $x $y $w $h ", length $_[0];#d#
750 750
751 my $inprogress = @{ $self->{bg_fetch} || [] }; 751 my $inprogress = @{ $self->{bg_fetch} || [] };
752 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $_[0]); 752 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $_[0]);
753 $self->bg_fetch unless $inprogress; 753 $self->bg_fetch unless $inprogress;
754 }; 754 };
1096 1096
1097 ## try to create single paragraphs of multiple lines sent by the server 1097 ## try to create single paragraphs of multiple lines sent by the server
1098 # no longer neecssary with TRT servers 1098 # no longer neecssary with TRT servers
1099 #$text =~ s/(?<=\S)\n(?=\w)/ /g; 1099 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
1100 1100
1101 for (split /\n/, $text) {
1102 ::message ({ 1101 ::message ({
1103 fg => $fg, 1102 fg => $fg,
1104 markup => $_, 1103 markup => $text,
1105 type => $type, 1104 type => $type,
1106 extra => [@extra], 1105 extra => [@extra],
1107 color_flags => $color, #d# ugly, kill 1106 color_flags => $color, #d# ugly, kill
1108 }); 1107 });
1109 1108
1110 $color &= ~NDI_CLEAR; # only clear once for multiline messages 1109# $color &= ~NDI_CLEAR; # only clear once for multiline messages
1111 # actually, this is an ugly design. _we_ should control the channels, 1110# # actually, this is an ugly design. _we_ should control the channels,
1112 # not some random other widget, as the channels are clearly protocol-specific. 1111# # not some random other widget, as the channels are clearly protocol-specific.
1113 # then we could also react to flags such as CLEAR without resorting to 1112# # then we could also react to flags such as CLEAR without resorting to
1114 # hacks such as color_flags, above. 1113# # hacks such as color_flags, above.
1115 }
1116 1114
1117 $self->{statusbox}->add ($text, 1115 $self->{statusbox}->add ($text,
1118 group => $text, 1116 group => $text,
1119 fg => $fg, 1117 fg => $fg,
1120 timeout => $color >= 2 ? 180 : 10, 1118 timeout => $color >= 2 ? 180 : 10,
1368 1366
1369 $self->update_server_info; 1367 $self->update_server_info;
1370 1368
1371 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; 1369 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
1372 $self->send_command ("pickup $::CFG->{pickup}"); 1370 $self->send_command ("pickup $::CFG->{pickup}");
1371
1372 $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]",
1373 DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d#
1373} 1374}
1374 1375
1375sub lookat { 1376sub lookat {
1376 my ($self, $x, $y) = @_; 1377 my ($self, $x, $y) = @_;
1377 1378

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines