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 | our $TEX_HIDDEN = new_from_resource DC::Texture # MUST be POT |
|
|
26 | "hidden-0.png", minify => 1, mipmap => 1, wrap => 1; |
|
|
27 | |
|
|
28 | sub MIN_TEXTURE_UNUSED() { 1 }#d# |
16 | |
29 | |
17 | sub new { |
30 | sub new { |
18 | my ($class, %arg) = @_; |
31 | my ($class, %arg) = @_; |
19 | |
32 | |
20 | my $self = $class->SUPER::new (%arg, |
33 | my $self = $class->SUPER::new (%arg, |
… | |
… | |
67 | for values %{delete $ws->{w} || {}}; |
80 | for values %{delete $ws->{w} || {}}; |
68 | } |
81 | } |
69 | |
82 | |
70 | delete $self->{items}; |
83 | delete $self->{items}; |
71 | $::INV->clear; |
84 | $::INV->clear; |
|
|
85 | $::INVR->clear; |
72 | $::INVR_HB->clear; |
86 | $::INVR_HB->clear; |
73 | $::FLOORBOX->clear; |
87 | $::FLOORBOX->clear; |
74 | }); |
88 | }); |
75 | |
89 | |
76 | $self->{map_widget}->add_command (@$_) |
90 | $self->{map_widget}->add_command (@$_) |
77 | for @cmd_help; |
91 | for @cmd_help; |
78 | |
92 | |
79 | { |
93 | { |
80 | $self->{dialogue} = my $tex = new_from_file DC::Texture |
94 | $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}}); |
95 | $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
83 | } |
96 | } |
84 | |
97 | |
85 | { |
98 | { |
86 | $self->{noface} = my $tex = new_from_file DC::Texture |
99 | $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}}); |
100 | $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
89 | } |
101 | } |
|
|
102 | |
|
|
103 | { |
|
|
104 | $self->{hidden} = my $tex = $TEX_HIDDEN; |
|
|
105 | $self->{map}->set_texture (3, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
|
|
106 | $self->{map_widget}{hidden_tex} = $tex;#d# |
|
|
107 | } |
|
|
108 | |
|
|
109 | # $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id |
|
|
110 | # $self->{expire_w} = EV::timer 1, 1, sub { |
|
|
111 | # my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1; |
|
|
112 | # |
|
|
113 | # for ($self->{map}->expire_textures ($self->{expire_count}, $count)) { |
|
|
114 | # warn DC::SvREFCNT $self->{texture}[$_]; |
|
|
115 | # $self->{texture}[$_]->unload; |
|
|
116 | # warn "expire texture $_\n";#d# |
|
|
117 | # } |
|
|
118 | # |
|
|
119 | # ($self->{expire_count} += $count) < @{ $self->{texture} } |
|
|
120 | # or $self->{expire_count} = DC::DB::FIRST_TILE_ID; |
|
|
121 | # warn "count is $count\n";#d# |
|
|
122 | # }; |
90 | |
123 | |
91 | $self->{open_container} = 0; |
124 | $self->{open_container} = 0; |
92 | |
125 | |
93 | # per server |
126 | # per server |
94 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
127 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
… | |
… | |
255 | my %wkw = ( |
288 | my %wkw = ( |
256 | root => $DC::UI::ROOT, |
289 | root => $DC::UI::ROOT, |
257 | tooltip => $DC::UI::TOOLTIP, |
290 | tooltip => $DC::UI::TOOLTIP, |
258 | |
291 | |
259 | mapwidget => $::MAPWIDGET, |
292 | mapwidget => $::MAPWIDGET, |
|
|
293 | menubar => $::MENUBAR, |
|
|
294 | menupopup => $::MENUPOPUP, |
|
|
295 | pickup_enable => $::PICKUP_ENABLE, |
260 | buttonbar => $::BUTTONBAR, |
296 | buttonbar => $::BUTTONBAR, |
261 | metaserver => $::METASERVER, |
297 | metaserver => $::METASERVER, |
262 | buttonbar => $::BUTTONBAR, |
298 | buttonbar => $::BUTTONBAR, |
263 | login_button => $::LOGIN_BUTTON, |
299 | login_button => $::LOGIN_BUTTON, |
264 | quit_dialog => $::QUIT_DIALOG, |
300 | quit_dialog => $::QUIT_DIALOG, |
… | |
… | |
281 | |
317 | |
282 | floorbox => $::FLOORBOX, |
318 | floorbox => $::FLOORBOX, |
283 | help_window => $::HELP_WINDOW, |
319 | help_window => $::HELP_WINDOW, |
284 | message_window => $::MESSAGE_WINDOW, |
320 | message_window => $::MESSAGE_WINDOW, |
285 | message_dist => $::MESSAGE_DIST, |
321 | message_dist => $::MESSAGE_DIST, |
286 | statusbox => $::SDTATUSBOX, |
322 | statusbox => $::STATUSBOX, |
287 | |
323 | |
288 | inv => $::INV, |
324 | inv => $::INV, |
289 | invr => $::INVR, |
325 | invr => $::INVR, |
290 | invr_hb => $::INVR_HB, |
326 | invr_hb => $::INVR_HB, |
291 | ); |
327 | ); |
… | |
… | |
375 | ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_}) |
411 | ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_}) |
376 | : () |
412 | : () |
377 | } |
413 | } |
378 | sort { $a <=> $b } keys %{$self->{spell_paths}}; |
414 | sort { $a <=> $b } keys %{$self->{spell_paths}}; |
379 | |
415 | |
380 | join "", @diff |
416 | "\u$name: " . (join ", ", @diff) |
381 | } |
417 | } |
382 | |
418 | |
383 | # all stats that are chacked against changes |
419 | # all stats that are chacked against changes |
384 | my @statchange = ( |
420 | my @statchange = ( |
385 | [&CS_STAT_STR => \&_stat_numdiff, "Str"], |
421 | [&CS_STAT_STR => \&_stat_numdiff, "Str"], |
… | |
… | |
440 | } |
476 | } |
441 | |
477 | |
442 | if ( |
478 | if ( |
443 | my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange |
479 | my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange |
444 | ) { |
480 | ) { |
445 | my $msg = "<b>stat change</b>: " . (join " ", @diffs); |
481 | 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); |
482 | $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 20); |
447 | } |
483 | } |
448 | |
484 | |
449 | $self->update_stats_window ($stats, $prev); |
485 | $self->update_stats_window ($stats, $prev); |
450 | |
486 | |
… | |
… | |
488 | |
524 | |
489 | $::GAUGES->{hp} ->set_value ($hp, $hp_m); |
525 | $::GAUGES->{hp} ->set_value ($hp, $hp_m); |
490 | $::GAUGES->{mana} ->set_value ($sp, $sp_m); |
526 | $::GAUGES->{mana} ->set_value ($sp, $sp_m); |
491 | $::GAUGES->{food} ->set_value ($fo, $fo_m); |
527 | $::GAUGES->{food} ->set_value ($fo, $fo_m); |
492 | $::GAUGES->{grace} ->set_value ($gr, $gr_m); |
528 | $::GAUGES->{grace} ->set_value ($gr, $gr_m); |
493 | $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64})) |
529 | $::GAUGES->{exp} ->set_label ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64}))#d# |
494 | . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); |
530 | . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); |
495 | $::GAUGES->{prg} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64}); |
531 | $::GAUGES->{exp} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64}); |
496 | $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE}); |
532 | $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE}); |
497 | my $title = $stats->{+CS_STAT_TITLE}; |
533 | my $title = $stats->{+CS_STAT_TITLE}; |
498 | $title =~ s/^Player: //; |
534 | $title =~ s/^Player: //; |
499 | $::STATWIDS->{title} ->set_text ("Title: " . $title); |
535 | $::STATWIDS->{title} ->set_text ("Title: " . $title); |
500 | |
536 | |
… | |
… | |
541 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
577 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
542 | ]; |
578 | ]; |
543 | |
579 | |
544 | my @add = @$sw; |
580 | my @add = @$sw; |
545 | |
581 | |
546 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; |
582 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>"; |
547 | |
583 | |
548 | my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
584 | 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); |
585 | my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
550 | |
586 | |
551 | my ($x, $y) = (0, 1); |
587 | my ($x, $y) = (0, 1); |
… | |
… | |
613 | my $sw = $self->{skillwid}{$idx}; |
649 | my $sw = $self->{skillwid}{$idx}; |
614 | $sw->[0]->set_text (::formsep ($val->[1])); |
650 | $sw->[0]->set_text (::formsep ($val->[1])); |
615 | $sw->[1]->set_text ($val->[0] * 1); |
651 | $sw->[1]->set_text ($val->[0] * 1); |
616 | $sw->[2]->set_value (@$val); |
652 | $sw->[2]->set_value (@$val); |
617 | |
653 | |
618 | $::GAUGES->{sklprg}->set_label ("$name %d%%"); |
654 | $::GAUGES->{skillexp}->set_label ("$name %d%%"); |
619 | $::GAUGES->{sklprg}->set_value (@$val); |
655 | $::GAUGES->{skillexp}->set_value (@$val); |
620 | } |
656 | } |
621 | } |
657 | } |
622 | |
658 | |
623 | sub user_send { |
659 | sub user_send { |
624 | my ($self, $command) = @_; |
660 | my ($self, $command) = @_; |
… | |
… | |
637 | } |
673 | } |
638 | |
674 | |
639 | sub map_scroll { |
675 | sub map_scroll { |
640 | my ($self, $dx, $dy) = @_; |
676 | my ($self, $dx, $dy) = @_; |
641 | |
677 | |
642 | $self->{map}->scroll ($dx, $dy); |
678 | $self->{map_widget}->scroll ($dx, $dy); |
643 | } |
679 | } |
644 | |
680 | |
645 | sub feed_map1a { |
681 | sub feed_map1a { |
646 | my ($self, $data) = @_; |
682 | my ($self, $data) = @_; |
647 | |
683 | |
… | |
… | |
651 | for my $tile (@$missing) { |
687 | for my $tile (@$missing) { |
652 | next if $self->{delay}{$tile}; |
688 | next if $self->{delay}{$tile}; |
653 | |
689 | |
654 | $delay = 1; |
690 | $delay = 1; |
655 | |
691 | |
656 | if (my $tex = $::CONN->{texture}[$tile]) { |
692 | if (my $tex = $self->{texture}[$tile]) { |
657 | $tex->upload; |
693 | $tex->upload; |
658 | } else { |
694 | } else { |
659 | $self->{delay}{$tile} = 1; |
695 | $self->{delay}{$tile} = 1; |
660 | |
696 | |
661 | # we assume the face is in-flight and will eventually come |
697 | # we assume the face is in-flight and will eventually arrive |
662 | push @{$self->{tile_cb}{$tile}}, sub { |
698 | push @{$self->{tile_cb}{$tile}}, sub { |
663 | delete $self->{delay}{$tile}; |
699 | delete $self->{delay}{$tile}; |
664 | $_[0]->upload; |
700 | $_[0]->upload; |
665 | }; |
701 | }; |
666 | } |
702 | } |
667 | } |
703 | } |
668 | |
704 | |
669 | if ($delay) { |
705 | if ($delay) { |
670 | # delay the map drawing a tiny bit in the hope of getting the missing fetched |
706 | # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched |
671 | EV::once undef, 0, 0.03, sub { |
707 | EV::once undef, 0, 0.03, sub { |
672 | $self->{map_widget}->update |
708 | $self->{map_widget}->update |
673 | if $self->{map_widget}; |
709 | if $self->{map_widget}; |
674 | }; |
710 | }; |
675 | } else { |
711 | } else { |
… | |
… | |
684 | } |
720 | } |
685 | |
721 | |
686 | sub flush_map { |
722 | sub flush_map { |
687 | my ($self) = @_; |
723 | my ($self) = @_; |
688 | |
724 | |
689 | my $map_info = delete $self->{map_info} |
725 | return unless $self->{map_info}; |
690 | or return; |
|
|
691 | |
726 | |
|
|
727 | for my $map_info (values %{ $self->{map_cache} || {} }) { |
692 | my ($hash, $x, $y, $w, $h) = @$map_info; |
728 | my ($hash, $rdata, $x, $y, $w, $h) = @$map_info; |
693 | |
729 | |
694 | my $data = Compress::LZF::compress $self->{map}->get_rect ($x, $y, $w, $h); |
730 | my $data = $self->{map}->get_rect ($x, $y, $w, $h); |
695 | $self->{map_cache_new}{$hash} = \$data; |
731 | |
|
|
732 | if ($data ne $$rdata) { |
|
|
733 | $map_info->[1] = \$data; |
|
|
734 | my $cdata = Compress::LZF::compress $data; |
696 | DC::DB::put $self->{mapcache} => $hash => $data, sub { }; |
735 | DC::DB::put $self->{mapcache} => $hash => $cdata, sub { }; |
|
|
736 | } |
|
|
737 | } |
697 | } |
738 | } |
698 | |
739 | |
699 | sub map_clear { |
740 | sub map_clear { |
700 | my ($self) = @_; |
741 | my ($self) = @_; |
701 | |
742 | |
702 | $self->flush_map; |
743 | $self->flush_map; |
|
|
744 | delete $self->{map_info}; |
703 | delete $self->{neigh_map}; |
745 | delete $self->{neigh_map}; |
704 | |
746 | |
705 | $self->{map}->clear; |
747 | $self->{map}->clear; |
706 | delete $self->{map_widget}{magicmap}; |
748 | delete $self->{map_widget}{magicmap}; |
707 | } |
749 | } |
… | |
… | |
728 | |
770 | |
729 | $self->bg_fetch; |
771 | $self->bg_fetch; |
730 | }; |
772 | }; |
731 | } |
773 | } |
732 | |
774 | |
733 | sub load_map($$$) { |
775 | sub load_map($$$$$$) { |
734 | my ($self, $hash, $x, $y) = @_; |
776 | my ($self, $hash, $x, $y, $w, $h) = @_; |
735 | |
777 | |
736 | my $gen = $self->{map_change_gen}; |
778 | my $map_info = $self->{map_cache}{$hash} = [$hash, \"", $x, $y, $w, $h]; |
737 | |
779 | |
738 | my $cb = sub { |
780 | my $cb = sub { |
739 | return unless $gen == $self->{map_change_gen}; |
781 | $map_info->[1] = \$_[0]; |
740 | |
782 | |
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} || [] }; |
783 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
749 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); |
784 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $_[0]); |
750 | $self->bg_fetch unless $inprogress; |
785 | $self->bg_fetch unless $inprogress; |
751 | } |
|
|
752 | }; |
786 | }; |
753 | |
787 | |
754 | if (my $rdata = $self->{map_cache_old}{$hash}) { |
788 | if (my $map_info = $self->{map_cache_old}{$hash}) { |
755 | $cb->($$rdata); |
789 | $cb->(${ $map_info->[1] }); |
756 | } else { |
790 | } else { |
|
|
791 | my $gen = $self->{map_change_gen}; |
|
|
792 | |
757 | DC::DB::get $self->{mapcache} => $hash, $cb; |
793 | DC::DB::get $self->{mapcache} => $hash, sub { |
|
|
794 | return unless $gen == $self->{map_change_gen}; |
|
|
795 | return unless defined $_[0]; |
|
|
796 | $cb->(Compress::LZF::decompress $_[0]); |
|
|
797 | }; |
758 | } |
798 | } |
759 | } |
799 | } |
760 | |
800 | |
761 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
801 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
762 | # (server resource,s latency, bandwidth), so this hack is warranted. |
802 | # (server resources, latency, bandwidth), so this hack is warranted. |
763 | # the right fix is to make real tiled maps with an overview file |
803 | # the right fix is to make real tiled maps with an overview file |
764 | sub send_mapinfo { |
804 | sub send_mapinfo { |
765 | my ($self, $data, $cb) = @_; |
805 | my ($self, $data, $cb) = @_; |
766 | |
806 | |
767 | if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { |
807 | if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { |
… | |
… | |
792 | } |
832 | } |
793 | |
833 | |
794 | # this method does a "flood fill" into every tile direction |
834 | # this method does a "flood fill" into every tile direction |
795 | # it assumes that tiles are arranged in a rectangular grid, |
835 | # 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. |
836 | # 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 |
837 | # failure to comply is harmless and results in display errors |
798 | # at worst. |
838 | # at worst. |
799 | sub flood_fill { |
839 | sub flood_fill { |
800 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
840 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
801 | |
841 | |
802 | # the server does not allow map paths > 6 |
842 | # the server does not allow map paths > 6 |
… | |
… | |
838 | return if $mode ne "spatial"; |
878 | return if $mode ne "spatial"; |
839 | |
879 | |
840 | $x += $self->{map}->ox; |
880 | $x += $self->{map}->ox; |
841 | $y += $self->{map}->oy; |
881 | $y += $self->{map}->oy; |
842 | |
882 | |
843 | $self->load_map ($hash, $x, $y) |
883 | $self->load_map ($hash, $x, $y, $w, $h) |
844 | unless $self->{neigh_map}{$hash}[5]++;#d# |
884 | unless $self->{neigh_map}{$hash}[5]++;#d# |
845 | |
885 | |
846 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
886 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
847 | |
887 | |
848 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
888 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
… | |
… | |
856 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
896 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
857 | |
897 | |
858 | $self->flush_map; |
898 | $self->flush_map; |
859 | |
899 | |
860 | ++$self->{map_change_gen}; |
900 | ++$self->{map_change_gen}; |
861 | $self->{map_cache_old} = delete $self->{map_cache_new}; |
901 | $self->{map_cache_old} = delete $self->{map_cache}; |
862 | |
902 | |
863 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
903 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
864 | |
904 | |
865 | my $mapmapw = $self->{mapmap}->{w}; |
905 | my $mapmapw = $self->{mapmap}->{w}; |
866 | my $mapmaph = $self->{mapmap}->{h}; |
906 | my $mapmaph = $self->{mapmap}->{h}; |
… | |
… | |
878 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
918 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
879 | |
919 | |
880 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
920 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
881 | $::STATWIDS->{map}->set_text ("Map: " . $map); |
921 | $::STATWIDS->{map}->set_text ("Map: " . $map); |
882 | |
922 | |
883 | $self->load_map ($hash, $x, $y); |
923 | $self->load_map ($hash, $x, $y, $w, $h); |
884 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
924 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
885 | } |
925 | } |
886 | |
926 | |
887 | sub face_find { |
927 | sub face_find { |
888 | my ($self, $facenum, $face, $cb) = @_; |
928 | my ($self, $facenum, $face, $cb) = @_; |
… | |
… | |
959 | |
999 | |
960 | my $tex = $self->{texture}[$tile] ||= |
1000 | my $tex = $self->{texture}[$tile] ||= |
961 | new DC::Texture |
1001 | new DC::Texture |
962 | tile => $tile, |
1002 | tile => $tile, |
963 | image => $data, delete_image => 1, |
1003 | image => $data, delete_image => 1, |
964 | minify => 1, mipmap => 1; |
1004 | minify => 1; |
965 | |
1005 | |
966 | if (my $cbs = delete $self->{tile_cb}{$tile}) { |
1006 | if (my $cbs = delete $self->{tile_cb}{$tile}) { |
967 | $_->($tex) for @$cbs; |
1007 | $_->($tex) for @$cbs; |
968 | } |
1008 | } |
969 | } |
1009 | } |
… | |
… | |
974 | my ($self, $num, $cb) = @_; |
1014 | my ($self, $num, $cb) = @_; |
975 | |
1015 | |
976 | push @{$self->{face_cb}{$num}}, $cb; |
1016 | push @{$self->{face_cb}{$num}}, $cb; |
977 | |
1017 | |
978 | defined wantarray |
1018 | defined wantarray |
979 | ? DC::guard { |
1019 | ? Guard::guard { |
980 | @{$self->{face_cb}{$num}} |
1020 | @{$self->{face_cb}{$num}} |
981 | = grep $_ != $cb, |
1021 | = grep $_ != $cb, |
982 | @{$self->{face_cb}{$num}}; |
1022 | @{$self->{face_cb}{$num}}; |
983 | } |
1023 | } |
984 | : () |
1024 | : () |
… | |
… | |
1088 | |
1128 | |
1089 | ## try to create single paragraphs of multiple lines sent by the server |
1129 | ## try to create single paragraphs of multiple lines sent by the server |
1090 | # no longer neecssary with TRT servers |
1130 | # no longer neecssary with TRT servers |
1091 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1131 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1092 | |
1132 | |
1093 | for (split /\n/, $text) { |
|
|
1094 | ::message ({ |
1133 | ::message ({ |
1095 | fg => $fg, |
1134 | fg => $fg, |
1096 | markup => $_, |
1135 | markup => $text, |
1097 | type => $type, |
1136 | type => $type, |
1098 | extra => [@extra], |
1137 | extra => [@extra], |
1099 | color_flags => $color, #d# ugly, kill |
1138 | color_flags => $color, #d# ugly, kill |
1100 | }); |
1139 | }); |
1101 | |
1140 | |
1102 | $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1141 | # $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1103 | # actually, this is an ugly design. _we_ should control the channels, |
1142 | # # actually, this is an ugly design. _we_ should control the channels, |
1104 | # not some random other widget, as the channels are clearly protocol-specific. |
1143 | # # 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 |
1144 | # # then we could also react to flags such as CLEAR without resorting to |
1106 | # hacks such as color_flags, above. |
1145 | # # hacks such as color_flags, above. |
1107 | } |
|
|
1108 | |
1146 | |
1109 | $self->{statusbox}->add ($text, |
1147 | $self->{statusbox}->add ($text, |
1110 | group => $text, |
1148 | group => $text, |
1111 | fg => $fg, |
1149 | fg => $fg, |
1112 | timeout => $color >= 2 ? 180 : 10, |
1150 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
1359 | }); |
1397 | }); |
1360 | |
1398 | |
1361 | $self->update_server_info; |
1399 | $self->update_server_info; |
1362 | |
1400 | |
1363 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1401 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1364 | $self->send_command ("pickup $::CFG->{pickup}"); |
1402 | $self->send_pickup ($::CFG->{pickup}); |
|
|
1403 | |
|
|
1404 | $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]", |
|
|
1405 | DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d# |
1365 | } |
1406 | } |
1366 | |
1407 | |
1367 | sub lookat { |
1408 | sub lookat { |
1368 | my ($self, $x, $y) = @_; |
1409 | my ($self, $x, $y) = @_; |
1369 | |
1410 | |
… | |
… | |
1533 | } |
1574 | } |
1534 | |
1575 | |
1535 | sub send { |
1576 | sub send { |
1536 | my ($self, $msg) = @_; |
1577 | my ($self, $msg) = @_; |
1537 | |
1578 | |
1538 | $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); |
1579 | $self->{textview}->add_paragraph ({ |
|
|
1580 | markup => |
|
|
1581 | "\n<span foreground='#ffff00'><b>" |
|
|
1582 | . (DC::asxml $msg) |
|
|
1583 | . "</b></span>" |
|
|
1584 | }); |
1539 | $self->{textview}->scroll_to_bottom; |
1585 | $self->{textview}->scroll_to_bottom; |
1540 | |
1586 | |
1541 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1587 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1542 | } |
1588 | } |
1543 | |
1589 | |