… | |
… | |
1168 | aio_rename "$filename~", $filename; |
1168 | aio_rename "$filename~", $filename; |
1169 | |
1169 | |
1170 | $filename =~ s%/[^/]+$%%; |
1170 | $filename =~ s%/[^/]+$%%; |
1171 | aio_pathsync $filename if $cf::USE_FSYNC; |
1171 | aio_pathsync $filename if $cf::USE_FSYNC; |
1172 | } else { |
1172 | } else { |
1173 | warn "FATAL: $filename~: $!\n"; |
1173 | warn "unable to save objects: $filename~: $!\n"; |
1174 | } |
1174 | } |
1175 | } else { |
1175 | } else { |
1176 | aio_unlink $filename; |
1176 | aio_unlink $filename; |
1177 | aio_unlink "$filename.pst"; |
1177 | aio_unlink "$filename.pst"; |
1178 | } |
1178 | } |
… | |
… | |
1862 | |
1862 | |
1863 | (my $path = $_[0]{path}) =~ s/\//$PATH_SEP/go; |
1863 | (my $path = $_[0]{path}) =~ s/\//$PATH_SEP/go; |
1864 | "$UNIQUEDIR/$path" |
1864 | "$UNIQUEDIR/$path" |
1865 | } |
1865 | } |
1866 | |
1866 | |
1867 | # and all this just because we cannot iterate over |
|
|
1868 | # all maps in C++... |
|
|
1869 | sub change_all_map_light { |
|
|
1870 | my ($change) = @_; |
|
|
1871 | |
|
|
1872 | $_->change_map_light ($change) |
|
|
1873 | for grep $_->outdoor, values %cf::MAP; |
|
|
1874 | } |
|
|
1875 | |
|
|
1876 | sub decay_objects { |
1867 | sub decay_objects { |
1877 | my ($self) = @_; |
1868 | my ($self) = @_; |
1878 | |
1869 | |
1879 | return if $self->{deny_reset}; |
1870 | return if $self->{deny_reset}; |
1880 | |
1871 | |
… | |
… | |
2042 | |
2033 | |
2043 | unless ($self->{deny_activate}) { |
2034 | unless ($self->{deny_activate}) { |
2044 | $self->decay_objects; |
2035 | $self->decay_objects; |
2045 | $self->fix_auto_apply; |
2036 | $self->fix_auto_apply; |
2046 | $self->update_buttons; |
2037 | $self->update_buttons; |
2047 | cf::cede_to_tick; |
|
|
2048 | $self->set_darkness_map; |
|
|
2049 | cf::cede_to_tick; |
2038 | cf::cede_to_tick; |
2050 | $self->activate; |
2039 | $self->activate; |
2051 | } |
2040 | } |
2052 | |
2041 | |
2053 | $self->{last_save} = $cf::RUNTIME; |
2042 | $self->{last_save} = $cf::RUNTIME; |
… | |
… | |
2804 | id => "party", |
2793 | id => "party", |
2805 | title => "Party", |
2794 | title => "Party", |
2806 | reply => "gsay ", |
2795 | reply => "gsay ", |
2807 | tooltip => "Messages and chat related to your party", |
2796 | tooltip => "Messages and chat related to your party", |
2808 | }, |
2797 | }, |
|
|
2798 | "c/death" => { |
|
|
2799 | id => "death", |
|
|
2800 | title => "Death", |
|
|
2801 | reply => undef, |
|
|
2802 | tooltip => "Reason for and more info about your most recent death", |
|
|
2803 | }, |
|
|
2804 | "c/say" => $SAY_CHANNEL, |
|
|
2805 | "c/chat" => $CHAT_CHANNEL, |
2809 | ); |
2806 | ); |
2810 | |
2807 | |
2811 | sub cf::client::send_msg { |
2808 | sub cf::client::send_msg { |
2812 | my ($self, $channel, $msg, $color, @extra) = @_; |
2809 | my ($self, $channel, $msg, $color, @extra) = @_; |
2813 | |
2810 | |
… | |
… | |
2818 | |
2815 | |
2819 | # check predefined channels, for the benefit of C |
2816 | # check predefined channels, for the benefit of C |
2820 | if ($CHANNEL{$channel}) { |
2817 | if ($CHANNEL{$channel}) { |
2821 | $channel = $CHANNEL{$channel}; |
2818 | $channel = $CHANNEL{$channel}; |
2822 | |
2819 | |
2823 | $self->ext_msg (channel_info => $channel) |
2820 | $self->ext_msg (channel_info => $channel); |
2824 | if $self->can_msg; |
|
|
2825 | |
|
|
2826 | $channel = $channel->{id}; |
2821 | $channel = $channel->{id}; |
2827 | |
2822 | |
2828 | } elsif (ref $channel) { |
2823 | } elsif (ref $channel) { |
2829 | # send meta info to client, if not yet sent |
2824 | # send meta info to client, if not yet sent |
2830 | unless (exists $self->{channel}{$channel->{id}}) { |
2825 | unless (exists $self->{channel}{$channel->{id}}) { |
2831 | $self->{channel}{$channel->{id}} = $channel; |
2826 | $self->{channel}{$channel->{id}} = $channel; |
2832 | $self->ext_msg (channel_info => $channel) |
2827 | $self->ext_msg (channel_info => $channel); |
2833 | if $self->can_msg; |
|
|
2834 | } |
2828 | } |
2835 | |
2829 | |
2836 | $channel = $channel->{id}; |
2830 | $channel = $channel->{id}; |
2837 | } |
2831 | } |
2838 | |
2832 | |
2839 | return unless @extra || length $msg; |
2833 | return unless @extra || length $msg; |
2840 | |
2834 | |
2841 | if ($self->can_msg) { |
|
|
2842 | # default colour, mask it out |
2835 | # default colour, mask it out |
2843 | $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) |
2836 | $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) |
2844 | if $color & cf::NDI_DEF; |
2837 | if $color & cf::NDI_DEF; |
2845 | |
2838 | |
2846 | my $pkt = "msg " |
2839 | my $pkt = "msg " |
2847 | . $self->{json_coder}->encode ( |
2840 | . $self->{json_coder}->encode ( |
2848 | [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra] |
2841 | [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra] |
2849 | ); |
2842 | ); |
2850 | |
2843 | |
2851 | # try lzf for large packets |
2844 | # try lzf for large packets |
2852 | $pkt = "lzf " . Compress::LZF::compress $pkt |
2845 | $pkt = "lzf " . Compress::LZF::compress $pkt |
2853 | if 1024 <= length $pkt and $self->{can_lzf}; |
2846 | if 1024 <= length $pkt and $self->{can_lzf}; |
2854 | |
2847 | |
2855 | # split very large packets |
2848 | # split very large packets |
2856 | if (8192 < length $pkt and $self->{can_lzf}) { |
2849 | if (8192 < length $pkt and $self->{can_lzf}) { |
2857 | $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt; |
2850 | $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt; |
2858 | $pkt = "frag"; |
2851 | $pkt = "frag"; |
2859 | } |
2852 | } |
2860 | |
2853 | |
2861 | $self->send_packet ($pkt); |
2854 | $self->send_packet ($pkt); |
2862 | } else { |
|
|
2863 | if ($color >= 0) { |
|
|
2864 | # replace some tags by gcfclient-compatible ones |
|
|
2865 | for ($msg) { |
|
|
2866 | 1 while |
|
|
2867 | s/<b>([^<]*)<\/b>/[b]${1}[\/b]/ |
|
|
2868 | || s/<i>([^<]*)<\/i>/[i]${1}[\/i]/ |
|
|
2869 | || s/<u>([^<]*)<\/u>/[ul]${1}[\/ul]/ |
|
|
2870 | || s/<tt>([^<]*)<\/tt>/[fixed]${1}[\/fixed]/ |
|
|
2871 | || s/<fg name=\"([^"]+)\">([^<]*)<\/fg>/[color=$1]${2}[\/color]/; |
|
|
2872 | } |
|
|
2873 | |
|
|
2874 | $color &= cf::NDI_COLOR_MASK; |
|
|
2875 | |
|
|
2876 | utf8::encode $msg; |
|
|
2877 | |
|
|
2878 | if (0 && $msg =~ /\[/) { |
|
|
2879 | # COMMAND/INFO |
|
|
2880 | $self->send_packet ("drawextinfo $color 10 8 $msg") |
|
|
2881 | } else { |
|
|
2882 | $msg =~ s/\[\/?(?:b|i|u|fixed|color)[^\]]*\]//g; |
|
|
2883 | $self->send_packet ("drawinfo $color $msg") |
|
|
2884 | } |
|
|
2885 | } |
|
|
2886 | } |
|
|
2887 | } |
2855 | } |
2888 | |
2856 | |
2889 | =item $client->ext_msg ($type, @msg) |
2857 | =item $client->ext_msg ($type, @msg) |
2890 | |
2858 | |
2891 | Sends an ext event to the client. |
2859 | Sends an ext event to the client. |
… | |
… | |
3401 | |
3369 | |
3402 | cf::init_experience; |
3370 | cf::init_experience; |
3403 | cf::init_anim; |
3371 | cf::init_anim; |
3404 | cf::init_attackmess; |
3372 | cf::init_attackmess; |
3405 | cf::init_dynamic; |
3373 | cf::init_dynamic; |
3406 | cf::init_block; |
|
|
3407 | |
3374 | |
3408 | $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority |
3375 | $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority |
3409 | |
3376 | |
3410 | # we must not ever block the main coroutine |
3377 | # we must not ever block the main coroutine |
3411 | local $Coro::idle = sub { |
3378 | local $Coro::idle = sub { |