ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.459 by root, Sat Dec 13 21:46:12 2008 UTC vs.
Revision 1.465 by root, Thu Jan 8 00:54:55 2009 UTC

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++...
1869sub change_all_map_light {
1870 my ($change) = @_;
1871
1872 $_->change_map_light ($change)
1873 for grep $_->outdoor, values %cf::MAP;
1874}
1875
1876sub decay_objects { 1867sub 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;
2780 id => "infobox", 2769 id => "infobox",
2781 title => "Body Parts", 2770 title => "Body Parts",
2782 reply => undef, 2771 reply => undef,
2783 tooltip => "Shows which body parts you posess and are available", 2772 tooltip => "Shows which body parts you posess and are available",
2784 }, 2773 },
2774 "c/statistics" => {
2775 id => "infobox",
2776 title => "Statistics",
2777 reply => undef,
2778 tooltip => "Shows your primary statistics",
2779 },
2785 "c/skills" => { 2780 "c/skills" => {
2786 id => "infobox", 2781 id => "infobox",
2787 title => "Skills", 2782 title => "Skills",
2788 reply => undef, 2783 reply => undef,
2789 tooltip => "Shows your experience per skill and item power", 2784 tooltip => "Shows your experience per skill and item power",
2785 },
2786 "c/resistances" => {
2787 id => "infobox",
2788 title => "Resistances",
2789 reply => undef,
2790 tooltip => "Shows your resistances",
2791 },
2792 "c/pets" => {
2793 id => "infobox",
2794 title => "Pets",
2795 reply => undef,
2796 tooltip => "Shows information abotu your pets/a specific pet",
2790 }, 2797 },
2791 "c/uptime" => { 2798 "c/uptime" => {
2792 id => "infobox", 2799 id => "infobox",
2793 title => "Uptime", 2800 title => "Uptime",
2794 reply => undef, 2801 reply => undef,
2804 id => "party", 2811 id => "party",
2805 title => "Party", 2812 title => "Party",
2806 reply => "gsay ", 2813 reply => "gsay ",
2807 tooltip => "Messages and chat related to your party", 2814 tooltip => "Messages and chat related to your party",
2808 }, 2815 },
2816 "c/death" => {
2817 id => "death",
2818 title => "Death",
2819 reply => undef,
2820 tooltip => "Reason for and more info about your most recent death",
2821 },
2822 "c/say" => $SAY_CHANNEL,
2823 "c/chat" => $CHAT_CHANNEL,
2809); 2824);
2810 2825
2811sub cf::client::send_msg { 2826sub cf::client::send_msg {
2812 my ($self, $channel, $msg, $color, @extra) = @_; 2827 my ($self, $channel, $msg, $color, @extra) = @_;
2813 2828
2818 2833
2819 # check predefined channels, for the benefit of C 2834 # check predefined channels, for the benefit of C
2820 if ($CHANNEL{$channel}) { 2835 if ($CHANNEL{$channel}) {
2821 $channel = $CHANNEL{$channel}; 2836 $channel = $CHANNEL{$channel};
2822 2837
2823 $self->ext_msg (channel_info => $channel) 2838 $self->ext_msg (channel_info => $channel);
2824 if $self->can_msg;
2825
2826 $channel = $channel->{id}; 2839 $channel = $channel->{id};
2827 2840
2828 } elsif (ref $channel) { 2841 } elsif (ref $channel) {
2829 # send meta info to client, if not yet sent 2842 # send meta info to client, if not yet sent
2830 unless (exists $self->{channel}{$channel->{id}}) { 2843 unless (exists $self->{channel}{$channel->{id}}) {
2831 $self->{channel}{$channel->{id}} = $channel; 2844 $self->{channel}{$channel->{id}} = $channel;
2832 $self->ext_msg (channel_info => $channel) 2845 $self->ext_msg (channel_info => $channel);
2833 if $self->can_msg;
2834 } 2846 }
2835 2847
2836 $channel = $channel->{id}; 2848 $channel = $channel->{id};
2837 } 2849 }
2838 2850
2839 return unless @extra || length $msg; 2851 return unless @extra || length $msg;
2840 2852
2841 if ($self->can_msg) {
2842 # default colour, mask it out 2853 # default colour, mask it out
2843 $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) 2854 $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF)
2844 if $color & cf::NDI_DEF; 2855 if $color & cf::NDI_DEF;
2845 2856
2846 my $pkt = "msg " 2857 my $pkt = "msg "
2847 . $self->{json_coder}->encode ( 2858 . $self->{json_coder}->encode (
2848 [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra] 2859 [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra]
2849 ); 2860 );
2850 2861
2851 # try lzf for large packets 2862 # try lzf for large packets
2852 $pkt = "lzf " . Compress::LZF::compress $pkt 2863 $pkt = "lzf " . Compress::LZF::compress $pkt
2853 if 1024 <= length $pkt and $self->{can_lzf}; 2864 if 1024 <= length $pkt and $self->{can_lzf};
2854 2865
2855 # split very large packets 2866 # split very large packets
2856 if (8192 < length $pkt and $self->{can_lzf}) { 2867 if (8192 < length $pkt and $self->{can_lzf}) {
2857 $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt; 2868 $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt;
2858 $pkt = "frag"; 2869 $pkt = "frag";
2859 } 2870 }
2860 2871
2861 $self->send_packet ($pkt); 2872 $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} 2873}
2888 2874
2889=item $client->ext_msg ($type, @msg) 2875=item $client->ext_msg ($type, @msg)
2890 2876
2891Sends an ext event to the client. 2877Sends an ext event to the client.
3401 3387
3402 cf::init_experience; 3388 cf::init_experience;
3403 cf::init_anim; 3389 cf::init_anim;
3404 cf::init_attackmess; 3390 cf::init_attackmess;
3405 cf::init_dynamic; 3391 cf::init_dynamic;
3406 cf::init_block;
3407 3392
3408 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority 3393 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority
3409 3394
3410 # we must not ever block the main coroutine 3395 # we must not ever block the main coroutine
3411 local $Coro::idle = sub { 3396 local $Coro::idle = sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines