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.192 by root, Thu Mar 27 20:42:23 2008 UTC vs.
Revision 1.214 by root, Tue Dec 22 00:35:44 2009 UTC

1package DC::Protocol; 1package DC::Protocol;
2 2
3use utf8; 3use utf8;
4use strict; 4use strict;
5
6use Guard ();
5 7
6use Deliantra::Protocol::Constants; 8use Deliantra::Protocol::Constants;
7 9
8use DC; 10use DC;
9use DC::DB; 11use DC::DB;
11use DC::Pod; 13use DC::Pod;
12use DC::Macro; 14use DC::Macro;
13use DC::Item; 15use DC::Item;
14 16
15use base 'Deliantra::Protocol::Base'; 17use base 'Deliantra::Protocol::Base';
18
19our $TEX_DIALOGUE = new_from_resource DC::Texture
20 "dialogue.png", minify => 1, mipmap => 1;
21
22our $TEX_NOFACE = new_from_resource DC::Texture
23 "noface.png", minify => 1, mipmap => 1, wrap => 1;
24
25sub MIN_TEXTURE_UNUSED() { 1 }#d#
16 26
17sub new { 27sub new {
18 my ($class, %arg) = @_; 28 my ($class, %arg) = @_;
19 29
20 my $self = $class->SUPER::new (%arg, 30 my $self = $class->SUPER::new (%arg,
64 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { 74 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub {
65 for my $ws (values %{delete $self->{widgetset} || {}}) { 75 for my $ws (values %{delete $self->{widgetset} || {}}) {
66 $_->destroy 76 $_->destroy
67 for values %{delete $ws->{w} || {}}; 77 for values %{delete $ws->{w} || {}};
68 } 78 }
79
80 delete $self->{items};
81 $::INV->clear;
82 $::INVR->clear;
83 $::INVR_HB->clear;
84 $::FLOORBOX->clear;
69 }); 85 });
70 86
71 $self->{map_widget}->add_command (@$_) 87 $self->{map_widget}->add_command (@$_)
72 for @cmd_help; 88 for @cmd_help;
73 89
74 { 90 {
75 $self->{dialogue} = my $tex = new_from_file DC::Texture 91 $self->{dialogue} = my $tex = $TEX_DIALOGUE;
76 DC::find_rcfile "dialogue.png", minify => 1, mipmap => 1;
77 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 92 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
78 } 93 }
79 94
80 { 95 {
81 $self->{noface} = my $tex = new_from_file DC::Texture 96 $self->{noface} = my $tex = $TEX_NOFACE;
82 DC::find_rcfile "noface.png", minify => 1, mipmap => 1;
83 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 97 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
84 } 98 }
99
100# $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id
101# $self->{expire_w} = EV::timer 1, 1, sub {
102# my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1;
103#
104# for ($self->{map}->expire_textures ($self->{expire_count}, $count)) {
105# warn DC::SvREFCNT $self->{texture}[$_];
106# $self->{texture}[$_]->unload;
107# warn "expire texture $_\n";#d#
108# }
109#
110# ($self->{expire_count} += $count) < @{ $self->{texture} }
111# or $self->{expire_count} = DC::DB::FIRST_TILE_ID;
112# warn "count is $count\n";#d#
113# };
85 114
86 $self->{open_container} = 0; 115 $self->{open_container} = 0;
87 116
88 # per server 117 # per server
89 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; 118 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";
250 my %wkw = ( 279 my %wkw = (
251 root => $DC::UI::ROOT, 280 root => $DC::UI::ROOT,
252 tooltip => $DC::UI::TOOLTIP, 281 tooltip => $DC::UI::TOOLTIP,
253 282
254 mapwidget => $::MAPWIDGET, 283 mapwidget => $::MAPWIDGET,
284 menubar => $::MENUBAR,
285 menupopup => $::MENUPOPUP,
286 pickup_enable => $::PICKUP_ENABLE,
255 buttonbar => $::BUTTONBAR, 287 buttonbar => $::BUTTONBAR,
256 metaserver => $::METASERVER, 288 metaserver => $::METASERVER,
257 buttonbar => $::BUTTONBAR, 289 buttonbar => $::BUTTONBAR,
258 login_button => $::LOGIN_BUTTON, 290 login_button => $::LOGIN_BUTTON,
259 quit_dialog => $::QUIT_DIALOG, 291 quit_dialog => $::QUIT_DIALOG,
276 308
277 floorbox => $::FLOORBOX, 309 floorbox => $::FLOORBOX,
278 help_window => $::HELP_WINDOW, 310 help_window => $::HELP_WINDOW,
279 message_window => $::MESSAGE_WINDOW, 311 message_window => $::MESSAGE_WINDOW,
280 message_dist => $::MESSAGE_DIST, 312 message_dist => $::MESSAGE_DIST,
281 statusbox => $::SDTATUSBOX, 313 statusbox => $::STATUSBOX,
282 314
283 inv => $::INV, 315 inv => $::INV,
284 invr => $::INVR, 316 invr => $::INVR,
285 invr_hb => $::INVR_HB, 317 invr_hb => $::INVR_HB,
286 ); 318 );
370 ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_}) 402 ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_})
371 : () 403 : ()
372 } 404 }
373 sort { $a <=> $b } keys %{$self->{spell_paths}}; 405 sort { $a <=> $b } keys %{$self->{spell_paths}};
374 406
375 join "", @diff 407 "\u$name: " . (join ", ", @diff)
376} 408}
377 409
378# all stats that are chacked against changes 410# all stats that are chacked against changes
379my @statchange = ( 411my @statchange = (
380 [&CS_STAT_STR => \&_stat_numdiff, "Str"], 412 [&CS_STAT_STR => \&_stat_numdiff, "Str"],
435 } 467 }
436 468
437 if ( 469 if (
438 my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange 470 my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange
439 ) { 471 ) {
440 my $msg = "<b>stat change</b>: " . (join " ", @diffs); 472 my $msg = "<b>stat change</b>: " . (join " ", map "($_)", @diffs);
441 $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 20); 473 $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 20);
442 } 474 }
443 475
444 $self->update_stats_window ($stats, $prev); 476 $self->update_stats_window ($stats, $prev);
445 477
483 515
484 $::GAUGES->{hp} ->set_value ($hp, $hp_m); 516 $::GAUGES->{hp} ->set_value ($hp, $hp_m);
485 $::GAUGES->{mana} ->set_value ($sp, $sp_m); 517 $::GAUGES->{mana} ->set_value ($sp, $sp_m);
486 $::GAUGES->{food} ->set_value ($fo, $fo_m); 518 $::GAUGES->{food} ->set_value ($fo, $fo_m);
487 $::GAUGES->{grace} ->set_value ($gr, $gr_m); 519 $::GAUGES->{grace} ->set_value ($gr, $gr_m);
488 $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64})) 520 $::GAUGES->{exp} ->set_label ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64}))#d#
489 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); 521 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")");
490 $::GAUGES->{prg} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64}); 522 $::GAUGES->{exp} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64});
491 $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE}); 523 $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE});
492 my $title = $stats->{+CS_STAT_TITLE}; 524 my $title = $stats->{+CS_STAT_TITLE};
493 $title =~ s/^Player: //; 525 $title =~ s/^Player: //;
494 $::STATWIDS->{title} ->set_text ("Title: " . $title); 526 $::STATWIDS->{title} ->set_text ("Title: " . $title);
495 527
536 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), 568 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0),
537 ]; 569 ];
538 570
539 my @add = @$sw; 571 my @add = @$sw;
540 572
541 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; 573 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>";
542 574
543 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 575 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
544 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 576 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
545 577
546 my ($x, $y) = (0, 1); 578 my ($x, $y) = (0, 1);
608 my $sw = $self->{skillwid}{$idx}; 640 my $sw = $self->{skillwid}{$idx};
609 $sw->[0]->set_text (::formsep ($val->[1])); 641 $sw->[0]->set_text (::formsep ($val->[1]));
610 $sw->[1]->set_text ($val->[0] * 1); 642 $sw->[1]->set_text ($val->[0] * 1);
611 $sw->[2]->set_value (@$val); 643 $sw->[2]->set_value (@$val);
612 644
613 $::GAUGES->{sklprg}->set_label ("$name %d%%"); 645 $::GAUGES->{skillexp}->set_label ("$name %d%%");
614 $::GAUGES->{sklprg}->set_value (@$val); 646 $::GAUGES->{skillexp}->set_value (@$val);
615 } 647 }
616} 648}
617 649
618sub user_send { 650sub user_send {
619 my ($self, $command) = @_; 651 my ($self, $command) = @_;
632} 664}
633 665
634sub map_scroll { 666sub map_scroll {
635 my ($self, $dx, $dy) = @_; 667 my ($self, $dx, $dy) = @_;
636 668
637 $self->{map}->scroll ($dx, $dy); 669 $self->{map_widget}->scroll ($dx, $dy);
638} 670}
639 671
640sub feed_map1a { 672sub feed_map1a {
641 my ($self, $data) = @_; 673 my ($self, $data) = @_;
642 674
646 for my $tile (@$missing) { 678 for my $tile (@$missing) {
647 next if $self->{delay}{$tile}; 679 next if $self->{delay}{$tile};
648 680
649 $delay = 1; 681 $delay = 1;
650 682
651 if (my $tex = $::CONN->{texture}[$tile]) { 683 if (my $tex = $self->{texture}[$tile]) {
652 $tex->upload; 684 $tex->upload;
653 } else { 685 } else {
654 $self->{delay}{$tile} = 1; 686 $self->{delay}{$tile} = 1;
655 687
656 # we assume the face is in-flight and will eventually come 688 # we assume the face is in-flight and will eventually arrive
657 push @{$self->{tile_cb}{$tile}}, sub { 689 push @{$self->{tile_cb}{$tile}}, sub {
658 delete $self->{delay}{$tile}; 690 delete $self->{delay}{$tile};
659 $_[0]->upload; 691 $_[0]->upload;
660 }; 692 };
661 } 693 }
662 } 694 }
663 695
664 if ($delay) { 696 if ($delay) {
665 # delay the map drawing a tiny bit in the hope of getting the missing fetched 697 # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched
666 EV::once undef, 0, 0.03, sub { 698 EV::once undef, 0, 0.03, sub {
667 $self->{map_widget}->update 699 $self->{map_widget}->update
668 if $self->{map_widget}; 700 if $self->{map_widget};
669 }; 701 };
670 } else { 702 } else {
679} 711}
680 712
681sub flush_map { 713sub flush_map {
682 my ($self) = @_; 714 my ($self) = @_;
683 715
684 my $map_info = delete $self->{map_info} 716 return unless $self->{map_info};
685 or return;
686 717
718 for my $map_info (values %{ $self->{map_cache} || {} }) {
687 my ($hash, $x, $y, $w, $h) = @$map_info; 719 my ($hash, $rdata, $x, $y, $w, $h) = @$map_info;
688 720
689 my $data = Compress::LZF::compress $self->{map}->get_rect ($x, $y, $w, $h); 721 my $data = $self->{map}->get_rect ($x, $y, $w, $h);
690 $self->{map_cache_new}{$hash} = \$data; 722
723 if ($data ne $$rdata) {
724 $map_info->[1] = \$data;
725 my $cdata = Compress::LZF::compress $data;
691 DC::DB::put $self->{mapcache} => $hash => $data, sub { }; 726 DC::DB::put $self->{mapcache} => $hash => $cdata, sub { };
727 }
728 }
692} 729}
693 730
694sub map_clear { 731sub map_clear {
695 my ($self) = @_; 732 my ($self) = @_;
696 733
697 $self->flush_map; 734 $self->flush_map;
735 delete $self->{map_info};
698 delete $self->{neigh_map}; 736 delete $self->{neigh_map};
699 737
700 $self->{map}->clear; 738 $self->{map}->clear;
701 delete $self->{map_widget}{magicmap}; 739 delete $self->{map_widget}{magicmap};
702} 740}
723 761
724 $self->bg_fetch; 762 $self->bg_fetch;
725 }; 763 };
726} 764}
727 765
728sub load_map($$$) { 766sub load_map($$$$$$) {
729 my ($self, $hash, $x, $y) = @_; 767 my ($self, $hash, $x, $y, $w, $h) = @_;
730 768
731 my $gen = $self->{map_change_gen}; 769 my $map_info = $self->{map_cache}{$hash} = [$hash, \"", $x, $y, $w, $h];
732 770
733 my $cb = sub { 771 my $cb = sub {
734 return unless $gen == $self->{map_change_gen}; 772 $map_info->[1] = \$_[0];
735 773
736 my ($data) = @_;
737
738 if (defined $data) {
739 $self->{map_cache_new}{$hash} = \$data;
740
741 my $data = Compress::LZF::decompress $data;
742
743 my $inprogress = @{ $self->{bg_fetch} || [] }; 774 my $inprogress = @{ $self->{bg_fetch} || [] };
744 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); 775 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $_[0]);
745 $self->bg_fetch unless $inprogress; 776 $self->bg_fetch unless $inprogress;
746 }
747 }; 777 };
748 778
749 if (my $rdata = $self->{map_cache_old}{$hash}) { 779 if (my $map_info = $self->{map_cache_old}{$hash}) {
750 $cb->($$rdata); 780 $cb->(${ $map_info->[1] });
751 } else { 781 } else {
782 my $gen = $self->{map_change_gen};
783
752 DC::DB::get $self->{mapcache} => $hash, $cb; 784 DC::DB::get $self->{mapcache} => $hash, sub {
785 return unless $gen == $self->{map_change_gen};
786 return unless defined $_[0];
787 $cb->(Compress::LZF::decompress $_[0]);
788 };
753 } 789 }
754} 790}
755 791
756# hardcode /world/world_xxx_xxx map names, the savings are enourmous, 792# hardcode /world/world_xxx_xxx map names, the savings are enourmous,
757# (server resource,s latency, bandwidth), so this hack is warranted. 793# (server resources, latency, bandwidth), so this hack is warranted.
758# the right fix is to make real tiled maps with an overview file 794# the right fix is to make real tiled maps with an overview file
759sub send_mapinfo { 795sub send_mapinfo {
760 my ($self, $data, $cb) = @_; 796 my ($self, $data, $cb) = @_;
761 797
762 if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { 798 if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) {
787} 823}
788 824
789# this method does a "flood fill" into every tile direction 825# this method does a "flood fill" into every tile direction
790# it assumes that tiles are arranged in a rectangular grid, 826# it assumes that tiles are arranged in a rectangular grid,
791# i.e. a map is the same as the left of the right map etc. 827# i.e. a map is the same as the left of the right map etc.
792# failure to comply are harmless and result in display errors 828# failure to comply is harmless and results in display errors
793# at worst. 829# at worst.
794sub flood_fill { 830sub flood_fill {
795 my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; 831 my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_;
796 832
797 # the server does not allow map paths > 6 833 # the server does not allow map paths > 6
833 return if $mode ne "spatial"; 869 return if $mode ne "spatial";
834 870
835 $x += $self->{map}->ox; 871 $x += $self->{map}->ox;
836 $y += $self->{map}->oy; 872 $y += $self->{map}->oy;
837 873
838 $self->load_map ($hash, $x, $y) 874 $self->load_map ($hash, $x, $y, $w, $h)
839 unless $self->{neigh_map}{$hash}[5]++;#d# 875 unless $self->{neigh_map}{$hash}[5]++;#d#
840 876
841 $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; 877 $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash];
842 878
843 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) 879 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags)
851 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 887 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
852 888
853 $self->flush_map; 889 $self->flush_map;
854 890
855 ++$self->{map_change_gen}; 891 ++$self->{map_change_gen};
856 $self->{map_cache_old} = delete $self->{map_cache_new}; 892 $self->{map_cache_old} = delete $self->{map_cache};
857 893
858 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 894 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
859 895
860 my $mapmapw = $self->{mapmap}->{w}; 896 my $mapmapw = $self->{mapmap}->{w};
861 my $mapmaph = $self->{mapmap}->{h}; 897 my $mapmaph = $self->{mapmap}->{h};
873 $self->{map_info} = [$hash, $x, $y, $w, $h]; 909 $self->{map_info} = [$hash, $x, $y, $w, $h];
874 910
875 (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; 911 (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/;
876 $::STATWIDS->{map}->set_text ("Map: " . $map); 912 $::STATWIDS->{map}->set_text ("Map: " . $map);
877 913
878 $self->load_map ($hash, $x, $y); 914 $self->load_map ($hash, $x, $y, $w, $h);
879 $self->flood_fill (0, 0, 0, "", $hash, $flags); 915 $self->flood_fill (0, 0, 0, "", $hash, $flags);
880} 916}
881 917
882sub face_find { 918sub face_find {
883 my ($self, $facenum, $face, $cb) = @_; 919 my ($self, $facenum, $face, $cb) = @_;
954 990
955 my $tex = $self->{texture}[$tile] ||= 991 my $tex = $self->{texture}[$tile] ||=
956 new DC::Texture 992 new DC::Texture
957 tile => $tile, 993 tile => $tile,
958 image => $data, delete_image => 1, 994 image => $data, delete_image => 1,
959 minify => 1, mipmap => 1; 995 minify => 1;
960 996
961 if (my $cbs = delete $self->{tile_cb}{$tile}) { 997 if (my $cbs = delete $self->{tile_cb}{$tile}) {
962 $_->($tex) for @$cbs; 998 $_->($tex) for @$cbs;
963 } 999 }
964} 1000}
969 my ($self, $num, $cb) = @_; 1005 my ($self, $num, $cb) = @_;
970 1006
971 push @{$self->{face_cb}{$num}}, $cb; 1007 push @{$self->{face_cb}{$num}}, $cb;
972 1008
973 defined wantarray 1009 defined wantarray
974 ? DC::guard { 1010 ? Guard::guard {
975 @{$self->{face_cb}{$num}} 1011 @{$self->{face_cb}{$num}}
976 = grep $_ != $cb, 1012 = grep $_ != $cb,
977 @{$self->{face_cb}{$num}}; 1013 @{$self->{face_cb}{$num}};
978 } 1014 }
979 : () 1015 : ()
1025 s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&amp;/g; 1061 s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&amp;/g;
1026 1062
1027 # handle some elements 1063 # handle some elements
1028 s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; 1064 s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs;
1029 s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; 1065 s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs;
1066
1067 s/\s+$//;
1030 1068
1031 $_ 1069 $_
1032} 1070}
1033 1071
1034our %NAME_TO_COLOR = ( 1072our %NAME_TO_COLOR = (
1081 1119
1082 ## try to create single paragraphs of multiple lines sent by the server 1120 ## try to create single paragraphs of multiple lines sent by the server
1083 # no longer neecssary with TRT servers 1121 # no longer neecssary with TRT servers
1084 #$text =~ s/(?<=\S)\n(?=\w)/ /g; 1122 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
1085 1123
1086 for (split /\n/, $text) {
1087 ::message ({ 1124 ::message ({
1088 fg => $fg, 1125 fg => $fg,
1089 markup => $_, 1126 markup => $text,
1090 type => $type, 1127 type => $type,
1091 extra => [@extra], 1128 extra => [@extra],
1092 color_flags => $color, #d# ugly, kill 1129 color_flags => $color, #d# ugly, kill
1093 }); 1130 });
1094 1131
1095 $color &= ~NDI_CLEAR; # only clear once for multiline messages 1132# $color &= ~NDI_CLEAR; # only clear once for multiline messages
1096 # actually, this is an ugly design. _we_ should control the channels, 1133# # actually, this is an ugly design. _we_ should control the channels,
1097 # not some random other widget, as the channels are clearly protocol-specific. 1134# # not some random other widget, as the channels are clearly protocol-specific.
1098 # then we could also react to flags such as CLEAR without resorting to 1135# # then we could also react to flags such as CLEAR without resorting to
1099 # hacks such as color_flags, above. 1136# # hacks such as color_flags, above.
1100 }
1101 1137
1102 $self->{statusbox}->add ($text, 1138 $self->{statusbox}->add ($text,
1103 group => $text, 1139 group => $text,
1104 fg => $fg, 1140 fg => $fg,
1105 timeout => $color >= 2 ? 180 : 10, 1141 timeout => $color >= 2 ? 180 : 10,
1170 $::FLOORBOX->clear; 1206 $::FLOORBOX->clear;
1171 1207
1172 my @add; 1208 my @add;
1173 1209
1174 my $row; 1210 my $row;
1175 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { 1211 for (sort { $b->{count} <=> $a->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) {
1212 next if $_->{tag} & 0x80000000;
1176 if ($row < 6) { 1213 if ($row < 6) {
1177 local $_->{face_widget}; # hack to force recreation of widget 1214 local $_->{face_widget}; # hack to force recreation of widget
1178 local $_->{desc_widget}; # hack to force recreation of widget 1215 local $_->{desc_widget}; # hack to force recreation of widget
1179 DC::Item::update_widgets $_; 1216 DC::Item::update_widgets $_;
1180 1217
1207sub set_opencont { 1244sub set_opencont {
1208 my ($conn, $tag, $name) = @_; 1245 my ($conn, $tag, $name) = @_;
1209 $conn->{open_container} = $tag; 1246 $conn->{open_container} = $tag;
1210 update_floorbox; 1247 update_floorbox;
1211 1248
1212 $::INVR_HB->clear (); 1249 $::INVR_HB->clear;
1213 $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name); 1250 $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name);
1214 1251
1215 if ($tag != 0) { # Floor isn't closable, is it? 1252 if ($tag != 0) { # Floor isn't closable, is it?
1216 $::INVR_HB->add (new DC::UI::Button 1253 $::INVR_HB->add (new DC::UI::Button
1217 text => "Close container", 1254 text => "Close container",
1273} 1310}
1274 1311
1275sub item_update { 1312sub item_update {
1276 my ($self, $item) = @_; 1313 my ($self, $item) = @_;
1277 1314
1278 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; 1315 #print "item_update: $item->{tag} in $item->{container} pt($self->{player}{tag}) oc($::CONN->{open_container}) f($item->{flags})\n";
1279 1316
1280 DC::Item::update_widgets $item; 1317 DC::Item::update_widgets $item;
1281 1318
1282 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { 1319 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) {
1283 set_opencont ($::CONN, 0, "Floor"); 1320 set_opencont ($::CONN, 0, "Floor");
1284 1321
1285 } elsif ($item->{flags} & F_OPEN) { 1322 } elsif ($item->{flags} & F_OPEN) {
1286 set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); 1323 set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item);
1351 }); 1388 });
1352 1389
1353 $self->update_server_info; 1390 $self->update_server_info;
1354 1391
1355 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; 1392 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
1356 $self->send_command ("pickup $::CFG->{pickup}"); 1393 $self->send_pickup ($::CFG->{pickup});
1394
1395 $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]",
1396 DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d#
1357} 1397}
1358 1398
1359sub lookat { 1399sub lookat {
1360 my ($self, $x, $y) = @_; 1400 my ($self, $x, $y) = @_;
1361 1401
1525} 1565}
1526 1566
1527sub send { 1567sub send {
1528 my ($self, $msg) = @_; 1568 my ($self, $msg) = @_;
1529 1569
1530 $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); 1570 $self->{textview}->add_paragraph ({
1571 markup =>
1572 "\n<span foreground='#ffff00'><b>"
1573 . (DC::asxml $msg)
1574 . "</b></span>"
1575 });
1531 $self->{textview}->scroll_to_bottom; 1576 $self->{textview}->scroll_to_bottom;
1532 1577
1533 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); 1578 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg);
1534} 1579}
1535 1580

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines