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.78 by elmex, Mon Aug 14 14:35:31 2006 UTC vs.
Revision 1.86 by root, Sun Oct 8 21:22:30 2006 UTC

12use base 'Crossfire::Protocol::Base'; 12use base 'Crossfire::Protocol::Base';
13 13
14sub new { 14sub new {
15 my $class = shift; 15 my $class = shift;
16 16
17 my $self = $class->SUPER::new (@_); 17 my $self = $class->SUPER::new (@_, setup_req => { extmap => 1 });
18 18
19 $self->{map_widget}->clr_commands; 19 $self->{map_widget}->clr_commands;
20 20
21 my @cmd_help = map { 21 my @cmd_help = map {
22 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x 22 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
42 for @cmd_help; 42 for @cmd_help;
43 43
44 $self->{noface} = new_from_file CFPlus::Texture 44 $self->{noface} = new_from_file CFPlus::Texture
45 CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1; 45 CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1;
46 46
47 {
48 $self->{dialogue} = my $tex = new_from_file CFPlus::Texture
49 CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1;
50 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
51 }
52
47 $self->{open_container} = 0; 53 $self->{open_container} = 0;
48 54
49 # "global" 55 # "global"
50 $self->{tilecache} = CFPlus::db_table "tilecache"; 56 $self->{tilecache} = CFPlus::db_table "tilecache"
57 or die "tilecache: unable to open database table";
51 $self->{facemap} = CFPlus::db_table "facemap"; 58 $self->{facemap} = CFPlus::db_table "facemap"
59 or die "facemap: unable to open database table";
52 60
53 # per server 61 # per server
54 $self->{mapcache} = CFPlus::db_table "mapcache_$self->{host}_$self->{port}"; 62 $self->{mapcache} = CFPlus::db_table "mapcache_$self->{host}_$self->{port}"
63 or die "mapcache_$self->{host}_$self->{port}: unable to open database table";
55 64
56 $self 65 $self
57} 66}
58 67
59sub logprint { 68sub logprint {
60 my ($self, @a) = @_; 69 my ($self, @a) = @_;
61 70
62 return;
63 $self->{log_fh} ||= do { 71 $self->{log_fh} ||= do {
64 my $path = "$Crossfire::VARDIR/log.$self->{host}"; 72 my $path = "$Crossfire::VARDIR/log.$self->{host}";
65 73
66 open my $fh, ">>:utf8", $path 74 open my $fh, ">>:utf8", $path
67 or die "Couldn't open logfile $path: $!"; 75 or die "Couldn't open logfile $path: $!";
340} 348}
341 349
342sub feed_map1a { 350sub feed_map1a {
343 my ($self, $data) = @_; 351 my ($self, $data) = @_;
344 352
345 $self->{map}->map1a_update ($data); 353 $self->{map}->map1a_update ($data, $self->{setup}{extmap});
346 $self->{map_widget}->update; 354 $self->{map_widget}->update;
347} 355}
348 356
349sub magicmap { 357sub magicmap {
350 my ($self, $w, $h, $x, $y, $data) = @_; 358 my ($self, $w, $h, $x, $y, $data) = @_;
615 [0.74, 0.65, 0.41], 623 [0.74, 0.65, 0.41],
616 ); 624 );
617 625
618 $self->logprint ("info: ", $text); 626 $self->logprint ("info: ", $text);
619 627
620 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
621
622 # try to create single paragraphs of multiple lines sent by the server 628 # try to create single paragraphs of multiple lines sent by the server
623 $text =~ s/(?<=\S)\n(?=\w)/ /g; 629 $text =~ s/(?<=\S)\n(?=\w)/ /g;
624 630
625 $text = CFPlus::asxml $text; 631 $text = CFPlus::asxml $text;
626 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 632 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
627 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 633 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
628 634
629 $self->{logview}->add_paragraph ({ fg => $color[$color], markup => $_ }) 635 ::message ({ fg => $color[$color], markup => $_ })
630 for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; 636 for split /\n/, $text;
631 $self->{logview}->scroll_to_bottom;
632 637
633 $self->{statusbox}->add ($text, 638 $self->{statusbox}->add ($text,
634 group => $text, 639 group => $text,
635 fg => $color[$color], 640 fg => $color[$color],
636 timeout => $color >= 2 ? 180 : 10, 641 timeout => $color >= 2 ? 180 : 10,
875 $::SERVER_INFO->set_markup ( 880 $::SERVER_INFO->set_markup (
876 "server <tt>$self->{host}:$self->{port}</tt>\n" 881 "server <tt>$self->{host}:$self->{port}</tt>\n"
877 . "protocol version <tt>$self->{version}</tt>\n" 882 . "protocol version <tt>$self->{version}</tt>\n"
878 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 883 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
879 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 884 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
885 . "editing support $yesno[!!$self->{editor_support}]\n"
886 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
880 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 887 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
881 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 888 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
882 . "map size $self->{mapw}×$self->{maph}\n" 889 . "map size $self->{mapw}×$self->{maph}\n"
883 ); 890 );
884} 891}
887 my ($self) = @_; 894 my ($self) = @_;
888 895
889 $self->send_ext_req (cfplus_support => version => 1, sub { 896 $self->send_ext_req (cfplus_support => version => 1, sub {
890 $self->{cfplus_ext} = $_[0]{version}; 897 $self->{cfplus_ext} = $_[0]{version};
891 $self->update_server_info; 898 $self->update_server_info;
899
900 if ($self->{cfplus_ext} >= 2) {
901 $self->send_ext_req ("editor_support", sub {
902 $self->{editor_support} = $_[0];
903 $self->update_server_info;
904
905 0
906 });
907 }
892 908
893 0 909 0
894 }); 910 });
895 911
896 $self->update_server_info; 912 $self->update_server_info;
923} 939}
924 940
925sub destroy { 941sub destroy {
926 my ($self) = @_; 942 my ($self) = @_;
927 943
928 $self->{npc_dialog}->destroy 944 (delete $self->{npc_dialog})->destroy
929 if $self->{npc_dialog}; 945 if $self->{npc_dialog};
930 946
931 $self->SUPER::destroy; 947 $self->SUPER::destroy;
932} 948}
933 949
1082 1098
1083 $self->SUPER::destroy; 1099 $self->SUPER::destroy;
1084} 1100}
1085 1101
10861 11021
1103

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines