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.134 by elmex, Wed Jul 25 15:06:19 2007 UTC vs.
Revision 1.138 by root, Sat Jul 28 16:48:45 2007 UTC

58 }); 58 });
59 59
60 $self->connect_ext (capabilities => sub { 60 $self->connect_ext (capabilities => sub {
61 my (%cap) = @_; 61 my (%cap) = @_;
62 62
63 #$self->send ("setup sound 0"); # we use a different protocol
64
63 $self->send_exti_msg (fx_want => { 65 $self->send_exti_msg (fx_want => {
64 3 => !!$::CFG->{bgm_enable}, # FT_MUSIC 66 3 => !!$::CFG->{bgm_enable}, # FT_MUSIC
65 5 => !!$::CFG->{audio_enable}, # FT_SOUND 67 #5 => !!$::CFG->{audio_enable}, # FT_SOUND
66 }); 68 });
67 69
68 if (my $ts = $cap{tileset}) { 70 if (my $ts = $cap{tileset}) {
69 if (my ($default) = grep $_->[2] & 1, @$ts) { 71 if (my ($default) = grep $_->[2] & 1, @$ts) {
70 $self->{tileset} = $default; 72 $self->{tileset} = $default;
189 191
190 # message window 192 # message window
191 $self->connect_ext (channel_info => sub { 193 $self->connect_ext (channel_info => sub {
192 my ($info) = @_; 194 my ($info) = @_;
193 $self->{channels}->{$info->{id}} = $info; 195 $self->{channels}->{$info->{id}} = $info;
194 $::MESSAGE_WINDOW->add_channel ($_[0]); 196 $::MESSAGE_WINDOW->add_channel ($info);
195 }); 197 });
196 198
197 # destroy widgets on logout 199 # destroy widgets on logout
198 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { 200 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub {
199 for my $ws (values %{delete $self->{widgetset} || {}}) { 201 for my $ws (values %{delete $self->{widgetset} || {}}) {
760 762
761 &::audio_music_set ($self->{songs}); 763 &::audio_music_set ($self->{songs});
762 }; 764 };
763 } 765 }
764 766
767 my $path = CFPlus::DB::path_of_res $face->{name};
768
765 if ($changed) { # new data 769 if ($changed) { # new data
766 my ($meta_json, $data) = unpack "(w/a*)*", delete $face->{data}; 770 my ($meta_json, $data) = unpack "(w/a*)*", delete $face->{data};
767 my $path = CFPlus::DB::path_of_res $face->{name};
768 771
769 CFPlus::DB::write_file $path, $data, sub { 772 CFPlus::DB::write_file $path, $data, sub {
770 CFPlus::DB::put "res-metadata" => $face->{name} => $meta_json, sub { 773 CFPlus::DB::put "res-metadata" => $face->{name} => $meta_json, sub {
771 $face->{meta} = $self->{json_coder}->decode ($meta_json); 774 $face->{meta} = $self->{json_coder}->decode ($meta_json);
772 $face->{path} = $path; 775 $face->{path} = $path;
774 $cb->(); 777 $cb->();
775 }; 778 };
776 }; 779 };
777 } else { 780 } else {
778 $face->{meta} = $self->{json_coder}->decode (delete $face->{data}); 781 $face->{meta} = $self->{json_coder}->decode (delete $face->{data});
782 $face->{path} = $path;
779 $cb->(); 783 $cb->();
780 } 784 }
781 } 785 }
782} 786}
783 787
814 } 818 }
815} 819}
816 820
817sub sound_play { 821sub sound_play {
818 my ($self, $x, $y, $soundnum, $type) = @_; 822 my ($self, $x, $y, $soundnum, $type) = @_;
823 warn "sound play <@_>\n";#d#
819 824
820 $self->{sound_play}->($x, $y, $soundnum, $type); 825 #$self->{sound_play}->($x, $y, $soundnum, $type);
821} 826}
822 827
823my $LAST_QUERY; # server is stupid, stupid, stupid 828my $LAST_QUERY; # server is stupid, stupid, stupid
824 829
825sub query { 830sub query {
890 $self->{$type} = $text; 895 $self->{$type} = $text;
891 } else { 896 } else {
892 $self->logprint ("msg: ", $text); 897 $self->logprint ("msg: ", $text);
893 return if $color < 0; # negative color == ignore if not understood 898 return if $color < 0; # negative color == ignore if not understood
894 899
895 my $fg = $CF_COLOR[$color % @CF_COLOR]; 900 my $fg = $CF_COLOR[$color & 0x1f] || [1, 0, 0];
896 901
897 ## try to create single paragraphs of multiple lines sent by the server 902 ## try to create single paragraphs of multiple lines sent by the server
898 # no longer neecssary with TRT servers 903 # no longer neecssary with TRT servers
899 #$text =~ s/(?<=\S)\n(?=\w)/ /g; 904 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
900 905
901 ::message ({ fg => $fg, markup => $_, type => $type }) 906 ::message ({ fg => $fg, markup => $_, type => $type, extra => [@extra] })
902 for split /\n/, $text; 907 for split /\n/, $text;
903 908
904 $self->{statusbox}->add ($text, 909 $self->{statusbox}->add ($text,
905 group => $text, 910 group => $text,
906 fg => $fg, 911 fg => $fg,
1162 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 1167 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
1163 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 1168 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
1164 . "map size $self->{mapw}×$self->{maph}\n" 1169 . "map size $self->{mapw}×$self->{maph}\n"
1165 ); 1170 );
1166 1171
1167 ::setup_build_button ($self->{editor_support}->{builder_ui});
1168} 1172}
1169 1173
1170sub logged_in { 1174sub logged_in {
1171 my ($self) = @_; 1175 my ($self) = @_;
1172 1176
1192 1196
1193 $self->send_command ("output-sync $::CFG->{output_sync}"); 1197 $self->send_command ("output-sync $::CFG->{output_sync}");
1194 $self->send_command ("output-count $::CFG->{output_count}"); 1198 $self->send_command ("output-count $::CFG->{output_count}");
1195 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; 1199 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
1196 $self->send_command ("pickup $::CFG->{pickup}"); 1200 $self->send_command ("pickup $::CFG->{pickup}");
1197}
1198
1199sub buildat {
1200 my ($self, $builditem, $x, $y) = @_;
1201
1202 if ($self->{cfplus_ext}) {
1203 $self->send_ext_msg (builder_build => dx => $x, dy => $y, (ref ($builditem) eq 'HASH') ? %$builditem : (item => $builditem));
1204 }
1205} 1201}
1206 1202
1207sub lookat { 1203sub lookat {
1208 my ($self, $x, $y) = @_; 1204 my ($self, $x, $y) = @_;
1209 1205

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines