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.75 by root, Sun Aug 13 19:47:05 2006 UTC vs.
Revision 1.87 by root, Tue Nov 7 22:41:27 2006 UTC

7 7
8use CFPlus; 8use CFPlus;
9use CFPlus::UI; 9use CFPlus::UI;
10use CFPlus::Pod; 10use CFPlus::Pod;
11 11
12use Crossfire::Protocol::Base 0.95;
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;
16 18
17 my $self = $class->SUPER::new (@_); 19 my $self = $class->SUPER::new (@_, setup_req => { extmap => 1 });
18 20
19 $self->{map_widget}->clr_commands; 21 $self->{map_widget}->clr_commands;
20 22
21 my @cmd_help = map { 23 my @cmd_help = map {
22 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x 24 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
34 36
35 map ["$cmd$_", $text], 37 map ["$cmd$_", $text],
36 sort { (length $a) <=> (length $b) } 38 sort { (length $a) <=> (length $b) }
37 @args 39 @args
38 } sort { $a->{par} <=> $b->{par} } 40 } sort { $a->{par} <=> $b->{par} }
39 CFPlus::Pod::find command_help => "*"; 41 CFPlus::Pod::find command => "*";
40 42
41 $self->{map_widget}->add_command (@$_) 43 $self->{map_widget}->add_command (@$_)
42 for @cmd_help; 44 for @cmd_help;
43 45
44 $self->{noface} = new_from_file CFPlus::Texture 46 $self->{noface} = new_from_file CFPlus::Texture
45 CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1; 47 CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1;
46 48
49 {
50 $self->{dialogue} = my $tex = new_from_file CFPlus::Texture
51 CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1;
52 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
53 }
54
47 $self->{open_container} = 0; 55 $self->{open_container} = 0;
48 56
49 # "global" 57 # "global"
50 $self->{tilecache} = CFPlus::db_table "tilecache"; 58 $self->{tilecache} = CFPlus::db_table "tilecache"
59 or die "tilecache: unable to open database table";
51 $self->{facemap} = CFPlus::db_table "facemap"; 60 $self->{facemap} = CFPlus::db_table "facemap"
61 or die "facemap: unable to open database table";
52 62
53 # per server 63 # per server
54 $self->{mapcache} = CFPlus::db_table "mapcache_$self->{host}_$self->{port}"; 64 $self->{mapcache} = CFPlus::db_table "mapcache_$self->{host}_$self->{port}"
65 or die "mapcache_$self->{host}_$self->{port}: unable to open database table";
55 66
56 $self 67 $self
57} 68}
58 69
59sub logprint { 70sub logprint {
310} 321}
311 322
312sub user_send { 323sub user_send {
313 my ($self, $command) = @_; 324 my ($self, $command) = @_;
314 325
315 if ($self->{record}) {
316 push @{$self->{record}}, $command; 326 push @{$self->{record}}, $command
317 } 327 if $self->{record};
318 328
319 $self->logprint ("send: ", $command); 329 $self->logprint ("send: ", $command);
320 $self->send_command ($command); 330 $self->send_command ($command);
321 ::status ($command); 331 ::status ($command);
322} 332}
339} 349}
340 350
341sub feed_map1a { 351sub feed_map1a {
342 my ($self, $data) = @_; 352 my ($self, $data) = @_;
343 353
344 $self->{map}->map1a_update ($data); 354 $self->{map}->map1a_update ($data, $self->{setup}{extmap});
345 $self->{map_widget}->update; 355 $self->{map_widget}->update;
346} 356}
347 357
348sub magicmap { 358sub magicmap {
349 my ($self, $w, $h, $x, $y, $data) = @_; 359 my ($self, $w, $h, $x, $y, $data) = @_;
614 [0.74, 0.65, 0.41], 624 [0.74, 0.65, 0.41],
615 ); 625 );
616 626
617 $self->logprint ("info: ", $text); 627 $self->logprint ("info: ", $text);
618 628
619 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
620
621 # 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
622 $text =~ s/(?<=\S)\n(?=\w)/ /g; 630 $text =~ s/(?<=\S)\n(?=\w)/ /g;
623 631
624 $text = CFPlus::asxml $text; 632 $text = CFPlus::asxml $text;
625 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 633 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
626 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 634 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
627 635
628 $self->{logview}->add_paragraph ({ fg => $color[$color], markup => $_ }) 636 ::message ({ fg => $color[$color], markup => $_ })
629 for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; 637 for split /\n/, $text;
630 $self->{logview}->scroll_to_bottom;
631 638
632 $self->{statusbox}->add ($text, 639 $self->{statusbox}->add ($text,
633 group => $text, 640 group => $text,
634 fg => $color[$color], 641 fg => $color[$color],
635 timeout => $color >= 2 ? 180 : 10, 642 timeout => $color >= 2 ? 180 : 10,
659 666
660sub spell_delete { 667sub spell_delete {
661 my ($self, $spell) = @_; 668 my ($self, $spell) = @_;
662 669
663 $::SPELL_PAGE->remove_spell ($spell); 670 $::SPELL_PAGE->remove_spell ($spell);
671}
672
673sub setup {
674 my ($self, $setup) = @_;
675
676 $::MAP->resize ($self->{mapw}, $self->{maph});
664} 677}
665 678
666sub addme_success { 679sub addme_success {
667 my ($self) = @_; 680 my ($self) = @_;
668 681
874 $::SERVER_INFO->set_markup ( 887 $::SERVER_INFO->set_markup (
875 "server <tt>$self->{host}:$self->{port}</tt>\n" 888 "server <tt>$self->{host}:$self->{port}</tt>\n"
876 . "protocol version <tt>$self->{version}</tt>\n" 889 . "protocol version <tt>$self->{version}</tt>\n"
877 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 890 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
878 . "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"
893 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
879 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 894 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
880 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 895 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
881 . "map size $self->{mapw}×$self->{maph}\n" 896 . "map size $self->{mapw}×$self->{maph}\n"
882 ); 897 );
883} 898}
886 my ($self) = @_; 901 my ($self) = @_;
887 902
888 $self->send_ext_req (cfplus_support => version => 1, sub { 903 $self->send_ext_req (cfplus_support => version => 1, sub {
889 $self->{cfplus_ext} = $_[0]{version}; 904 $self->{cfplus_ext} = $_[0]{version};
890 $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 }
891 915
892 0 916 0
893 }); 917 });
894 918
895 $self->update_server_info; 919 $self->update_server_info;
922} 946}
923 947
924sub destroy { 948sub destroy {
925 my ($self) = @_; 949 my ($self) = @_;
926 950
927 $self->{npc_dialog}->destroy 951 (delete $self->{npc_dialog})->destroy
928 if $self->{npc_dialog}; 952 if $self->{npc_dialog};
929 953
930 $self->SUPER::destroy; 954 $self->SUPER::destroy;
931} 955}
932 956
933package CFPlus::NPCDialog; 957package CFPlus::NPCDialog;
934 958
935our @ISA = 'CFPlus::UI::FancyFrame'; 959our @ISA = 'CFPlus::UI::Toplevel';
936 960
937sub new { 961sub new {
938 my $class = shift; 962 my $class = shift;
939 963
940 my $self = $class->SUPER::new ( 964 my $self = $class->SUPER::new (
1081 1105
1082 $self->SUPER::destroy; 1106 $self->SUPER::destroy;
1083} 1107}
1084 1108
10851 11091
1110

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines