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.83 by root, Tue Sep 19 22:02:38 2006 UTC vs.
Revision 1.88 by root, Sun Nov 19 20:31:29 2006 UTC

6use Crossfire::Protocol::Constants; 6use Crossfire::Protocol::Constants;
7 7
8use CFPlus; 8use CFPlus;
9use CFPlus::UI; 9use CFPlus::UI;
10use CFPlus::Pod; 10use CFPlus::Pod;
11
12use Crossfire::Protocol::Base 0.95;
11 13
12use base 'Crossfire::Protocol::Base'; 14use base 'Crossfire::Protocol::Base';
13 15
14sub new { 16sub new {
15 my $class = shift; 17 my $class = shift;
319} 321}
320 322
321sub user_send { 323sub user_send {
322 my ($self, $command) = @_; 324 my ($self, $command) = @_;
323 325
324 if ($self->{record}) {
325 push @{$self->{record}}, $command; 326 push @{$self->{record}}, $command
326 } 327 if $self->{record};
327 328
328 $self->logprint ("send: ", $command); 329 $self->logprint ("send: ", $command);
329 $self->send_command ($command); 330 $self->send_command ($command);
330 ::status ($command); 331 ::status ($command);
331} 332}
623 [0.74, 0.65, 0.41], 624 [0.74, 0.65, 0.41],
624 ); 625 );
625 626
626 $self->logprint ("info: ", $text); 627 $self->logprint ("info: ", $text);
627 628
628 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
629
630 # try to create single paragraphs of multiple lines sent by the server 629 # try to create single paragraphs of multiple lines sent by the server
631 $text =~ s/(?<=\S)\n(?=\w)/ /g; 630 $text =~ s/(?<=\S)\n(?=\w)/ /g;
632 631
633 $text = CFPlus::asxml $text; 632 $text = CFPlus::asxml $text;
634 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 633 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
635 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 634 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
636 635
637 $self->{logview}->add_paragraph ({ fg => $color[$color], markup => $_ }) 636 ::message ({ fg => $color[$color], markup => $_ })
638 for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; 637 for split /\n/, $text;
639 $self->{logview}->scroll_to_bottom;
640 638
641 $self->{statusbox}->add ($text, 639 $self->{statusbox}->add ($text,
642 group => $text, 640 group => $text,
643 fg => $color[$color], 641 fg => $color[$color],
644 timeout => $color >= 2 ? 180 : 10, 642 timeout => $color >= 2 ? 180 : 10,
658 # try to create single paragraphs out of the multiple lines sent by the server 656 # try to create single paragraphs out of the multiple lines sent by the server
659 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; 657 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g;
660 $spell->{message} =~ s/\n+$//; 658 $spell->{message} =~ s/\n+$//;
661 $spell->{message} ||= "Server did not provide a description for this spell."; 659 $spell->{message} ||= "Server did not provide a description for this spell.";
662 660
663 $::SPELL_PAGE->add_spell ($spell); 661 $::SPELL_LIST->add_spell ($spell);
664 662
665 $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message}); 663 $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message});
666 $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message}); 664 $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message});
667} 665}
668 666
669sub spell_delete { 667sub spell_delete {
670 my ($self, $spell) = @_; 668 my ($self, $spell) = @_;
671 669
672 $::SPELL_PAGE->remove_spell ($spell); 670 $::SPELL_LIST->remove_spell ($spell);
671}
672
673sub setup {
674 my ($self, $setup) = @_;
675
676 $::MAP->resize ($self->{mapw}, $self->{maph});
673} 677}
674 678
675sub addme_success { 679sub addme_success {
676 my ($self) = @_; 680 my ($self) = @_;
677 681
883 $::SERVER_INFO->set_markup ( 887 $::SERVER_INFO->set_markup (
884 "server <tt>$self->{host}:$self->{port}</tt>\n" 888 "server <tt>$self->{host}:$self->{port}</tt>\n"
885 . "protocol version <tt>$self->{version}</tt>\n" 889 . "protocol version <tt>$self->{version}</tt>\n"
886 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 890 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
887 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 891 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
892 . "editing support $yesno[!!$self->{editor_support}]\n"
888 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 893 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
889 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 894 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
890 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 895 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
891 . "map size $self->{mapw}×$self->{maph}\n" 896 . "map size $self->{mapw}×$self->{maph}\n"
892 ); 897 );
896 my ($self) = @_; 901 my ($self) = @_;
897 902
898 $self->send_ext_req (cfplus_support => version => 1, sub { 903 $self->send_ext_req (cfplus_support => version => 1, sub {
899 $self->{cfplus_ext} = $_[0]{version}; 904 $self->{cfplus_ext} = $_[0]{version};
900 $self->update_server_info; 905 $self->update_server_info;
906
907 if ($self->{cfplus_ext} >= 2) {
908 $self->send_ext_req ("editor_support", sub {
909 $self->{editor_support} = $_[0];
910 $self->update_server_info;
911
912 0
913 });
914 }
901 915
902 0 916 0
903 }); 917 });
904 918
905 $self->update_server_info; 919 $self->update_server_info;
1091 1105
1092 $self->SUPER::destroy; 1106 $self->SUPER::destroy;
1093} 1107}
1094 1108
10951 11091
1110

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines