1 | package DC::Protocol; |
1 | package DC::Protocol; |
2 | |
2 | |
3 | use utf8; |
3 | use utf8; |
4 | use strict; |
4 | use strict; |
|
|
5 | |
|
|
6 | use Guard (); |
5 | |
7 | |
6 | use Deliantra::Protocol::Constants; |
8 | use Deliantra::Protocol::Constants; |
7 | |
9 | |
8 | use DC; |
10 | use DC; |
9 | use DC::DB; |
11 | use DC::DB; |
… | |
… | |
11 | use DC::Pod; |
13 | use DC::Pod; |
12 | use DC::Macro; |
14 | use DC::Macro; |
13 | use DC::Item; |
15 | use DC::Item; |
14 | |
16 | |
15 | use base 'Deliantra::Protocol::Base'; |
17 | use base 'Deliantra::Protocol::Base'; |
|
|
18 | |
|
|
19 | our $TEX_DIALOGUE = new_from_resource DC::Texture |
|
|
20 | "dialogue.png", minify => 1, mipmap => 1; |
|
|
21 | |
|
|
22 | our $TEX_NOFACE = new_from_resource DC::Texture |
|
|
23 | "noface.png", minify => 1, mipmap => 1, wrap => 1; |
|
|
24 | |
|
|
25 | sub MIN_TEXTURE_UNUSED() { 1 }#d# |
16 | |
26 | |
17 | sub new { |
27 | sub 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, |
… | |
… | |
67 | for values %{delete $ws->{w} || {}}; |
77 | for values %{delete $ws->{w} || {}}; |
68 | } |
78 | } |
69 | |
79 | |
70 | delete $self->{items}; |
80 | delete $self->{items}; |
71 | $::INV->clear; |
81 | $::INV->clear; |
|
|
82 | $::INVR->clear; |
72 | $::INVR_HB->clear; |
83 | $::INVR_HB->clear; |
73 | $::FLOORBOX->clear; |
84 | $::FLOORBOX->clear; |
74 | }); |
85 | }); |
75 | |
86 | |
76 | $self->{map_widget}->add_command (@$_) |
87 | $self->{map_widget}->add_command (@$_) |
77 | for @cmd_help; |
88 | for @cmd_help; |
78 | |
89 | |
79 | { |
90 | { |
80 | $self->{dialogue} = my $tex = new_from_file DC::Texture |
91 | $self->{dialogue} = my $tex = $TEX_DIALOGUE; |
81 | DC::find_rcfile "dialogue.png", minify => 1, mipmap => 1; |
|
|
82 | $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}}); |
83 | } |
93 | } |
84 | |
94 | |
85 | { |
95 | { |
86 | $self->{noface} = my $tex = new_from_file DC::Texture |
96 | $self->{noface} = my $tex = $TEX_NOFACE; |
87 | DC::find_rcfile "noface.png", minify => 1, mipmap => 1; |
|
|
88 | $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}}); |
89 | } |
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 | # }; |
90 | |
114 | |
91 | $self->{open_container} = 0; |
115 | $self->{open_container} = 0; |
92 | |
116 | |
93 | # per server |
117 | # per server |
94 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
118 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
… | |
… | |
255 | my %wkw = ( |
279 | my %wkw = ( |
256 | root => $DC::UI::ROOT, |
280 | root => $DC::UI::ROOT, |
257 | tooltip => $DC::UI::TOOLTIP, |
281 | tooltip => $DC::UI::TOOLTIP, |
258 | |
282 | |
259 | mapwidget => $::MAPWIDGET, |
283 | mapwidget => $::MAPWIDGET, |
|
|
284 | menubar => $::MENUBAR, |
|
|
285 | menupopup => $::MENUPOPUP, |
|
|
286 | pickup_enable => $::PICKUP_ENABLE, |
260 | buttonbar => $::BUTTONBAR, |
287 | buttonbar => $::BUTTONBAR, |
261 | metaserver => $::METASERVER, |
288 | metaserver => $::METASERVER, |
262 | buttonbar => $::BUTTONBAR, |
289 | buttonbar => $::BUTTONBAR, |
263 | login_button => $::LOGIN_BUTTON, |
290 | login_button => $::LOGIN_BUTTON, |
264 | quit_dialog => $::QUIT_DIALOG, |
291 | quit_dialog => $::QUIT_DIALOG, |
… | |
… | |
281 | |
308 | |
282 | floorbox => $::FLOORBOX, |
309 | floorbox => $::FLOORBOX, |
283 | help_window => $::HELP_WINDOW, |
310 | help_window => $::HELP_WINDOW, |
284 | message_window => $::MESSAGE_WINDOW, |
311 | message_window => $::MESSAGE_WINDOW, |
285 | message_dist => $::MESSAGE_DIST, |
312 | message_dist => $::MESSAGE_DIST, |
286 | statusbox => $::SDTATUSBOX, |
313 | statusbox => $::STATUSBOX, |
287 | |
314 | |
288 | inv => $::INV, |
315 | inv => $::INV, |
289 | invr => $::INVR, |
316 | invr => $::INVR, |
290 | invr_hb => $::INVR_HB, |
317 | invr_hb => $::INVR_HB, |
291 | ); |
318 | ); |
… | |
… | |
375 | ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_}) |
402 | ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_}) |
376 | : () |
403 | : () |
377 | } |
404 | } |
378 | sort { $a <=> $b } keys %{$self->{spell_paths}}; |
405 | sort { $a <=> $b } keys %{$self->{spell_paths}}; |
379 | |
406 | |
380 | join "", @diff |
407 | "\u$name: " . (join ", ", @diff) |
381 | } |
408 | } |
382 | |
409 | |
383 | # all stats that are chacked against changes |
410 | # all stats that are chacked against changes |
384 | my @statchange = ( |
411 | my @statchange = ( |
385 | [&CS_STAT_STR => \&_stat_numdiff, "Str"], |
412 | [&CS_STAT_STR => \&_stat_numdiff, "Str"], |
… | |
… | |
440 | } |
467 | } |
441 | |
468 | |
442 | if ( |
469 | if ( |
443 | my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange |
470 | my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange |
444 | ) { |
471 | ) { |
445 | my $msg = "<b>stat change</b>: " . (join " ", @diffs); |
472 | my $msg = "<b>stat change</b>: " . (join " ", map "($_)", @diffs); |
446 | $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); |
447 | } |
474 | } |
448 | |
475 | |
449 | $self->update_stats_window ($stats, $prev); |
476 | $self->update_stats_window ($stats, $prev); |
450 | |
477 | |
… | |
… | |
488 | |
515 | |
489 | $::GAUGES->{hp} ->set_value ($hp, $hp_m); |
516 | $::GAUGES->{hp} ->set_value ($hp, $hp_m); |
490 | $::GAUGES->{mana} ->set_value ($sp, $sp_m); |
517 | $::GAUGES->{mana} ->set_value ($sp, $sp_m); |
491 | $::GAUGES->{food} ->set_value ($fo, $fo_m); |
518 | $::GAUGES->{food} ->set_value ($fo, $fo_m); |
492 | $::GAUGES->{grace} ->set_value ($gr, $gr_m); |
519 | $::GAUGES->{grace} ->set_value ($gr, $gr_m); |
493 | $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64})) |
520 | $::GAUGES->{exp} ->set_label ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64}))#d# |
494 | . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); |
521 | . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); |
495 | $::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}); |
496 | $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE}); |
523 | $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE}); |
497 | my $title = $stats->{+CS_STAT_TITLE}; |
524 | my $title = $stats->{+CS_STAT_TITLE}; |
498 | $title =~ s/^Player: //; |
525 | $title =~ s/^Player: //; |
499 | $::STATWIDS->{title} ->set_text ("Title: " . $title); |
526 | $::STATWIDS->{title} ->set_text ("Title: " . $title); |
500 | |
527 | |
… | |
… | |
541 | 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), |
542 | ]; |
569 | ]; |
543 | |
570 | |
544 | my @add = @$sw; |
571 | my @add = @$sw; |
545 | |
572 | |
546 | 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>"; |
547 | |
574 | |
548 | 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); |
549 | 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); |
550 | |
577 | |
551 | my ($x, $y) = (0, 1); |
578 | my ($x, $y) = (0, 1); |
… | |
… | |
613 | my $sw = $self->{skillwid}{$idx}; |
640 | my $sw = $self->{skillwid}{$idx}; |
614 | $sw->[0]->set_text (::formsep ($val->[1])); |
641 | $sw->[0]->set_text (::formsep ($val->[1])); |
615 | $sw->[1]->set_text ($val->[0] * 1); |
642 | $sw->[1]->set_text ($val->[0] * 1); |
616 | $sw->[2]->set_value (@$val); |
643 | $sw->[2]->set_value (@$val); |
617 | |
644 | |
618 | $::GAUGES->{sklprg}->set_label ("$name %d%%"); |
645 | $::GAUGES->{skillexp}->set_label ("$name %d%%"); |
619 | $::GAUGES->{sklprg}->set_value (@$val); |
646 | $::GAUGES->{skillexp}->set_value (@$val); |
620 | } |
647 | } |
621 | } |
648 | } |
622 | |
649 | |
623 | sub user_send { |
650 | sub user_send { |
624 | my ($self, $command) = @_; |
651 | my ($self, $command) = @_; |
… | |
… | |
637 | } |
664 | } |
638 | |
665 | |
639 | sub map_scroll { |
666 | sub map_scroll { |
640 | my ($self, $dx, $dy) = @_; |
667 | my ($self, $dx, $dy) = @_; |
641 | |
668 | |
642 | $self->{map}->scroll ($dx, $dy); |
669 | $self->{map_widget}->scroll ($dx, $dy); |
643 | } |
670 | } |
644 | |
671 | |
645 | sub feed_map1a { |
672 | sub feed_map1a { |
646 | my ($self, $data) = @_; |
673 | my ($self, $data) = @_; |
647 | |
674 | |
… | |
… | |
651 | for my $tile (@$missing) { |
678 | for my $tile (@$missing) { |
652 | next if $self->{delay}{$tile}; |
679 | next if $self->{delay}{$tile}; |
653 | |
680 | |
654 | $delay = 1; |
681 | $delay = 1; |
655 | |
682 | |
656 | if (my $tex = $::CONN->{texture}[$tile]) { |
683 | if (my $tex = $self->{texture}[$tile]) { |
657 | $tex->upload; |
684 | $tex->upload; |
658 | } else { |
685 | } else { |
659 | $self->{delay}{$tile} = 1; |
686 | $self->{delay}{$tile} = 1; |
660 | |
687 | |
661 | # we assume the face is in-flight and will eventually come |
688 | # we assume the face is in-flight and will eventually arrive |
662 | push @{$self->{tile_cb}{$tile}}, sub { |
689 | push @{$self->{tile_cb}{$tile}}, sub { |
663 | delete $self->{delay}{$tile}; |
690 | delete $self->{delay}{$tile}; |
664 | $_[0]->upload; |
691 | $_[0]->upload; |
665 | }; |
692 | }; |
666 | } |
693 | } |
667 | } |
694 | } |
668 | |
695 | |
669 | if ($delay) { |
696 | if ($delay) { |
670 | # 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 |
671 | EV::once undef, 0, 0.03, sub { |
698 | EV::once undef, 0, 0.03, sub { |
672 | $self->{map_widget}->update |
699 | $self->{map_widget}->update |
673 | if $self->{map_widget}; |
700 | if $self->{map_widget}; |
674 | }; |
701 | }; |
675 | } else { |
702 | } else { |
… | |
… | |
684 | } |
711 | } |
685 | |
712 | |
686 | sub flush_map { |
713 | sub flush_map { |
687 | my ($self) = @_; |
714 | my ($self) = @_; |
688 | |
715 | |
689 | my $map_info = delete $self->{map_info} |
716 | return unless $self->{map_info}; |
690 | or return; |
|
|
691 | |
717 | |
|
|
718 | for my $map_info (values %{ $self->{map_cache} || {} }) { |
692 | my ($hash, $x, $y, $w, $h) = @$map_info; |
719 | my ($hash, $rdata, $x, $y, $w, $h) = @$map_info; |
693 | |
720 | |
694 | my $data = Compress::LZF::compress $self->{map}->get_rect ($x, $y, $w, $h); |
721 | my $data = $self->{map}->get_rect ($x, $y, $w, $h); |
695 | $self->{map_cache_new}{$hash} = \$data; |
722 | |
|
|
723 | if ($data ne $$rdata) { |
|
|
724 | $map_info->[1] = \$data; |
|
|
725 | my $cdata = Compress::LZF::compress $data; |
696 | DC::DB::put $self->{mapcache} => $hash => $data, sub { }; |
726 | DC::DB::put $self->{mapcache} => $hash => $cdata, sub { }; |
|
|
727 | } |
|
|
728 | } |
697 | } |
729 | } |
698 | |
730 | |
699 | sub map_clear { |
731 | sub map_clear { |
700 | my ($self) = @_; |
732 | my ($self) = @_; |
701 | |
733 | |
702 | $self->flush_map; |
734 | $self->flush_map; |
|
|
735 | delete $self->{map_info}; |
703 | delete $self->{neigh_map}; |
736 | delete $self->{neigh_map}; |
704 | |
737 | |
705 | $self->{map}->clear; |
738 | $self->{map}->clear; |
706 | delete $self->{map_widget}{magicmap}; |
739 | delete $self->{map_widget}{magicmap}; |
707 | } |
740 | } |
… | |
… | |
728 | |
761 | |
729 | $self->bg_fetch; |
762 | $self->bg_fetch; |
730 | }; |
763 | }; |
731 | } |
764 | } |
732 | |
765 | |
733 | sub load_map($$$) { |
766 | sub load_map($$$$$$) { |
734 | my ($self, $hash, $x, $y) = @_; |
767 | my ($self, $hash, $x, $y, $w, $h) = @_; |
735 | |
768 | |
736 | my $gen = $self->{map_change_gen}; |
769 | my $map_info = $self->{map_cache}{$hash} = [$hash, \"", $x, $y, $w, $h]; |
737 | |
770 | |
738 | my $cb = sub { |
771 | my $cb = sub { |
739 | return unless $gen == $self->{map_change_gen}; |
772 | $map_info->[1] = \$_[0]; |
740 | |
773 | |
741 | my ($data) = @_; |
|
|
742 | |
|
|
743 | if (defined $data) { |
|
|
744 | $self->{map_cache_new}{$hash} = \$data; |
|
|
745 | |
|
|
746 | my $data = Compress::LZF::decompress $data; |
|
|
747 | |
|
|
748 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
774 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
749 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); |
775 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $_[0]); |
750 | $self->bg_fetch unless $inprogress; |
776 | $self->bg_fetch unless $inprogress; |
751 | } |
|
|
752 | }; |
777 | }; |
753 | |
778 | |
754 | if (my $rdata = $self->{map_cache_old}{$hash}) { |
779 | if (my $map_info = $self->{map_cache_old}{$hash}) { |
755 | $cb->($$rdata); |
780 | $cb->(${ $map_info->[1] }); |
756 | } else { |
781 | } else { |
|
|
782 | my $gen = $self->{map_change_gen}; |
|
|
783 | |
757 | 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 | }; |
758 | } |
789 | } |
759 | } |
790 | } |
760 | |
791 | |
761 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
792 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
762 | # (server resource,s latency, bandwidth), so this hack is warranted. |
793 | # (server resources, latency, bandwidth), so this hack is warranted. |
763 | # 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 |
764 | sub send_mapinfo { |
795 | sub send_mapinfo { |
765 | my ($self, $data, $cb) = @_; |
796 | my ($self, $data, $cb) = @_; |
766 | |
797 | |
767 | 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)$%) { |
… | |
… | |
792 | } |
823 | } |
793 | |
824 | |
794 | # this method does a "flood fill" into every tile direction |
825 | # this method does a "flood fill" into every tile direction |
795 | # it assumes that tiles are arranged in a rectangular grid, |
826 | # it assumes that tiles are arranged in a rectangular grid, |
796 | # 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. |
797 | # failure to comply are harmless and result in display errors |
828 | # failure to comply is harmless and results in display errors |
798 | # at worst. |
829 | # at worst. |
799 | sub flood_fill { |
830 | sub flood_fill { |
800 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
831 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
801 | |
832 | |
802 | # the server does not allow map paths > 6 |
833 | # the server does not allow map paths > 6 |
… | |
… | |
838 | return if $mode ne "spatial"; |
869 | return if $mode ne "spatial"; |
839 | |
870 | |
840 | $x += $self->{map}->ox; |
871 | $x += $self->{map}->ox; |
841 | $y += $self->{map}->oy; |
872 | $y += $self->{map}->oy; |
842 | |
873 | |
843 | $self->load_map ($hash, $x, $y) |
874 | $self->load_map ($hash, $x, $y, $w, $h) |
844 | unless $self->{neigh_map}{$hash}[5]++;#d# |
875 | unless $self->{neigh_map}{$hash}[5]++;#d# |
845 | |
876 | |
846 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
877 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
847 | |
878 | |
848 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
879 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
… | |
… | |
856 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
887 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
857 | |
888 | |
858 | $self->flush_map; |
889 | $self->flush_map; |
859 | |
890 | |
860 | ++$self->{map_change_gen}; |
891 | ++$self->{map_change_gen}; |
861 | $self->{map_cache_old} = delete $self->{map_cache_new}; |
892 | $self->{map_cache_old} = delete $self->{map_cache}; |
862 | |
893 | |
863 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
894 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
864 | |
895 | |
865 | my $mapmapw = $self->{mapmap}->{w}; |
896 | my $mapmapw = $self->{mapmap}->{w}; |
866 | my $mapmaph = $self->{mapmap}->{h}; |
897 | my $mapmaph = $self->{mapmap}->{h}; |
… | |
… | |
878 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
909 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
879 | |
910 | |
880 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
911 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
881 | $::STATWIDS->{map}->set_text ("Map: " . $map); |
912 | $::STATWIDS->{map}->set_text ("Map: " . $map); |
882 | |
913 | |
883 | $self->load_map ($hash, $x, $y); |
914 | $self->load_map ($hash, $x, $y, $w, $h); |
884 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
915 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
885 | } |
916 | } |
886 | |
917 | |
887 | sub face_find { |
918 | sub face_find { |
888 | my ($self, $facenum, $face, $cb) = @_; |
919 | my ($self, $facenum, $face, $cb) = @_; |
… | |
… | |
959 | |
990 | |
960 | my $tex = $self->{texture}[$tile] ||= |
991 | my $tex = $self->{texture}[$tile] ||= |
961 | new DC::Texture |
992 | new DC::Texture |
962 | tile => $tile, |
993 | tile => $tile, |
963 | image => $data, delete_image => 1, |
994 | image => $data, delete_image => 1, |
964 | minify => 1, mipmap => 1; |
995 | minify => 1; |
965 | |
996 | |
966 | if (my $cbs = delete $self->{tile_cb}{$tile}) { |
997 | if (my $cbs = delete $self->{tile_cb}{$tile}) { |
967 | $_->($tex) for @$cbs; |
998 | $_->($tex) for @$cbs; |
968 | } |
999 | } |
969 | } |
1000 | } |
… | |
… | |
974 | my ($self, $num, $cb) = @_; |
1005 | my ($self, $num, $cb) = @_; |
975 | |
1006 | |
976 | push @{$self->{face_cb}{$num}}, $cb; |
1007 | push @{$self->{face_cb}{$num}}, $cb; |
977 | |
1008 | |
978 | defined wantarray |
1009 | defined wantarray |
979 | ? DC::guard { |
1010 | ? Guard::guard { |
980 | @{$self->{face_cb}{$num}} |
1011 | @{$self->{face_cb}{$num}} |
981 | = grep $_ != $cb, |
1012 | = grep $_ != $cb, |
982 | @{$self->{face_cb}{$num}}; |
1013 | @{$self->{face_cb}{$num}}; |
983 | } |
1014 | } |
984 | : () |
1015 | : () |
… | |
… | |
1088 | |
1119 | |
1089 | ## 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 |
1090 | # no longer neecssary with TRT servers |
1121 | # no longer neecssary with TRT servers |
1091 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1122 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1092 | |
1123 | |
1093 | for (split /\n/, $text) { |
|
|
1094 | ::message ({ |
1124 | ::message ({ |
1095 | fg => $fg, |
1125 | fg => $fg, |
1096 | markup => $_, |
1126 | markup => $text, |
1097 | type => $type, |
1127 | type => $type, |
1098 | extra => [@extra], |
1128 | extra => [@extra], |
1099 | color_flags => $color, #d# ugly, kill |
1129 | color_flags => $color, #d# ugly, kill |
1100 | }); |
1130 | }); |
1101 | |
1131 | |
1102 | $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1132 | # $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1103 | # actually, this is an ugly design. _we_ should control the channels, |
1133 | # # actually, this is an ugly design. _we_ should control the channels, |
1104 | # 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. |
1105 | # 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 |
1106 | # hacks such as color_flags, above. |
1136 | # # hacks such as color_flags, above. |
1107 | } |
|
|
1108 | |
1137 | |
1109 | $self->{statusbox}->add ($text, |
1138 | $self->{statusbox}->add ($text, |
1110 | group => $text, |
1139 | group => $text, |
1111 | fg => $fg, |
1140 | fg => $fg, |
1112 | timeout => $color >= 2 ? 180 : 10, |
1141 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
1359 | }); |
1388 | }); |
1360 | |
1389 | |
1361 | $self->update_server_info; |
1390 | $self->update_server_info; |
1362 | |
1391 | |
1363 | $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; |
1364 | $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# |
1365 | } |
1397 | } |
1366 | |
1398 | |
1367 | sub lookat { |
1399 | sub lookat { |
1368 | my ($self, $x, $y) = @_; |
1400 | my ($self, $x, $y) = @_; |
1369 | |
1401 | |
… | |
… | |
1533 | } |
1565 | } |
1534 | |
1566 | |
1535 | sub send { |
1567 | sub send { |
1536 | my ($self, $msg) = @_; |
1568 | my ($self, $msg) = @_; |
1537 | |
1569 | |
1538 | $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 | }); |
1539 | $self->{textview}->scroll_to_bottom; |
1576 | $self->{textview}->scroll_to_bottom; |
1540 | |
1577 | |
1541 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1578 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1542 | } |
1579 | } |
1543 | |
1580 | |