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.319 by root, Tue Jul 24 15:56:45 2007 UTC vs.
Revision 1.327 by root, Wed Aug 1 17:22:51 2007 UTC

1921 $self->set_darkness_map; 1921 $self->set_darkness_map;
1922 Coro::cede; 1922 Coro::cede;
1923 $self->activate; 1923 $self->activate;
1924 } 1924 }
1925 1925
1926 $self->{last_save} = $cf::RUNTIME;
1927 $self->last_access ($cf::RUNTIME);
1928
1926 $self->in_memory (cf::MAP_IN_MEMORY); 1929 $self->in_memory (cf::MAP_IN_MEMORY);
1927 } 1930 }
1928 1931
1929 $self->post_load; 1932 $self->post_load;
1930} 1933}
2512sub cf::client::send_msg { 2515sub cf::client::send_msg {
2513 my ($self, $channel, $msg, $color, @extra) = @_; 2516 my ($self, $channel, $msg, $color, @extra) = @_;
2514 2517
2515 $msg = $self->pl->expand_cfpod ($msg); 2518 $msg = $self->pl->expand_cfpod ($msg);
2516 2519
2517 $color &= ~cf::NDI_UNIQUE; # just in case... 2520 $color &= cf::NDI_CLIENT_MASK; # just in case...
2518 2521
2519 if (ref $channel) { 2522 if (ref $channel) {
2520 # send meta info to client, if not yet sent 2523 # send meta info to client, if not yet sent
2521 unless (exists $self->{channel}{$channel->{id}}) { 2524 unless (exists $self->{channel}{$channel->{id}}) {
2522 $self->{channel}{$channel->{id}} = $channel; 2525 $self->{channel}{$channel->{id}} = $channel;
2527 } 2530 }
2528 2531
2529 return unless @extra || length $msg; 2532 return unless @extra || length $msg;
2530 2533
2531 if ($self->can_msg) { 2534 if ($self->can_msg) {
2535 # default colour, mask it out
2536 $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF)
2537 if $color & cf::NDI_DEF;
2538
2532 $self->send_packet ("msg " . $self->{json_coder}->encode ([$color, $channel, $msg, @extra])); 2539 $self->send_packet ("msg " . $self->{json_coder}->encode (
2540 [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra]));
2533 } else { 2541 } else {
2534 # replace some tags by gcfclient-compatible ones
2535 for ($msg) {
2536 1 while
2537 s/<b>([^<]*)<\/b>/[b]${1}[\/b]/
2538 || s/<i>([^<]*)<\/i>/[i]${1}[\/i]/
2539 || s/<u>([^<]*)<\/u>/[ul]${1}[\/ul]/
2540 || s/<tt>([^<]*)<\/tt>/[fixed]${1}[\/fixed]/
2541 || s/<fg name=\"([^"]+)\">([^<]*)<\/fg>/[color=$1]${2}[\/color]/;
2542 }
2543
2544 if ($color >= 0) { 2542 if ($color >= 0) {
2543 # replace some tags by gcfclient-compatible ones
2544 for ($msg) {
2545 1 while
2546 s/<b>([^<]*)<\/b>/[b]${1}[\/b]/
2547 || s/<i>([^<]*)<\/i>/[i]${1}[\/i]/
2548 || s/<u>([^<]*)<\/u>/[ul]${1}[\/ul]/
2549 || s/<tt>([^<]*)<\/tt>/[fixed]${1}[\/fixed]/
2550 || s/<fg name=\"([^"]+)\">([^<]*)<\/fg>/[color=$1]${2}[\/color]/;
2551 }
2552
2553 $color &= cf::NDI_COLOR_MASK;
2554
2555 utf8::encode $msg;
2556
2545 if (0 && $msg =~ /\[/) { 2557 if (0 && $msg =~ /\[/) {
2546 $self->send_packet ("drawextinfo $color 4 0 $msg") 2558 $self->send_packet ("drawextinfo $color 4 0 $msg")
2547 } else { 2559 } else {
2548 $msg =~ s/\[\/?(?:b|i|u|fixed|color)[^\]]*\]//g; 2560 $msg =~ s/\[\/?(?:b|i|u|fixed|color)[^\]]*\]//g;
2549 $self->send_packet ("drawinfo $color $msg") 2561 $self->send_packet ("drawinfo $color $msg")
2865 # TODO: for gcfclient pleasure, we should give resources 2877 # TODO: for gcfclient pleasure, we should give resources
2866 # that gcfclient doesn't grok a >10000 face index. 2878 # that gcfclient doesn't grok a >10000 face index.
2867 my $res = $facedata->{resource}; 2879 my $res = $facedata->{resource};
2868 my $enc = JSON::XS->new->utf8->canonical; 2880 my $enc = JSON::XS->new->utf8->canonical;
2869 2881
2882 my $soundconf = delete $res->{"res/sound.conf"};
2883
2870 while (my ($name, $info) = each %$res) { 2884 while (my ($name, $info) = each %$res) {
2871 my $meta = $enc->encode ({ 2885 my $meta = $enc->encode ({
2872 name => $name, 2886 name => $name,
2873 copyright => $info->{copyright}, #TODO# 2887 %{ $info->{meta} || {} },
2874 }); 2888 });
2875 2889
2876 my $idx = (cf::face::find $name) || cf::face::alloc $name; 2890 my $idx = (cf::face::find $name) || cf::face::alloc $name;
2877 2891
2878 if ($info->{type} & 1) { 2892 if ($info->{type} & 1) {
2887 } 2901 }
2888 2902
2889 cf::face::set_type $idx, $info->{type}; 2903 cf::face::set_type $idx, $info->{type};
2890 2904
2891 cf::cede_to_tick; 2905 cf::cede_to_tick;
2906 }
2907
2908 if ($soundconf) {
2909 $soundconf = $enc->decode (delete $soundconf->{data});
2910
2911 for (0 .. SOUND_CAST_SPELL_0 - 1) {
2912 my $sound = $soundconf->{compat}[$_]
2913 or next;
2914
2915 my $face = cf::face::find "sound/$sound->[1]";
2916 cf::sound::set $sound->[0] => $face;
2917 cf::sound::old_sound_index $_, $face; # gcfclient-compat
2918 }
2919
2920 while (my ($k, $v) = each %{$soundconf->{event}}) {
2921 my $face = cf::face::find "sound/$v";
2922 cf::sound::set $k => $face;
2923 }
2892 } 2924 }
2893 } 2925 }
2894 2926
2895 1 2927 1
2896} 2928}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines