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.316 by root, Mon Jul 23 21:02:50 2007 UTC vs.
Revision 1.326 by root, Tue Jul 31 17:33:15 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;
2523 $self->ext_msg (channel_info => %$channel); 2526 $self->ext_msg (channel_info => $channel);
2524 } 2527 }
2525 2528
2526 $channel = $channel->{id}; 2529 $channel = $channel->{id};
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
2545 if (0 && $msg =~ /\[/) { 2555 if (0 && $msg =~ /\[/) {
2546 $self->send_packet ("drawextinfo $color 4 0 $msg") 2556 $self->send_packet ("drawextinfo $color 4 0 $msg")
2547 } else { 2557 } else {
2548 $msg =~ s/\[\/?(?:b|i|u|fixed|color)[^\]]*\]//g; 2558 $msg =~ s/\[\/?(?:b|i|u|fixed|color)[^\]]*\]//g;
2549 $self->send_packet ("drawinfo $color $msg") 2559 $self->send_packet ("drawinfo $color $msg")
2865 # TODO: for gcfclient pleasure, we should give resources 2875 # TODO: for gcfclient pleasure, we should give resources
2866 # that gcfclient doesn't grok a >10000 face index. 2876 # that gcfclient doesn't grok a >10000 face index.
2867 my $res = $facedata->{resource}; 2877 my $res = $facedata->{resource};
2868 my $enc = JSON::XS->new->utf8->canonical; 2878 my $enc = JSON::XS->new->utf8->canonical;
2869 2879
2880 my $soundconf = delete $res->{"res/sound.conf"};
2881
2870 while (my ($name, $info) = each %$res) { 2882 while (my ($name, $info) = each %$res) {
2871 my $meta = $enc->encode ({ 2883 my $meta = $enc->encode ({
2872 name => $name, 2884 name => $name,
2873 type => $info->{type}, 2885 %{ $info->{meta} || {} },
2874 copyright => $info->{copyright}, #TODO#
2875 }); 2886 });
2876 2887
2877 my $idx = (cf::face::find $name) || cf::face::alloc $name; 2888 my $idx = (cf::face::find $name) || cf::face::alloc $name;
2878 2889
2879 if ($name =~ /\.jpg$/) { 2890 if ($info->{type} & 1) {
2880 cf::face::set_data $idx, 0, $info->{data}, $info->{chksum};#d# temp hack 2891 # prepend meta info
2881 cf::face::set_data $idx, 1, $info->{data}, $info->{chksum};#d# temp hack 2892
2882 } else {
2883 my $data = pack "(w/a*)*", $meta, $info->{data}; 2893 my $data = pack "(w/a*)*", $meta, $info->{data};
2884 my $chk = Digest::MD5::md5 "$info->{chksum},$meta"; # mangle data checksum and metadata 2894 my $chk = Digest::MD5::md5 "$info->{chksum},$meta"; # mangle data checksum and metadata
2885 2895
2886 cf::face::set_type $idx, 1;
2887 cf::face::set_data $idx, 0, $data, $chk; 2896 cf::face::set_data $idx, 0, $data, $chk;
2897 } else {
2898 cf::face::set_data $idx, 0, $info->{data}, $info->{chksum};
2888 } 2899 }
2889 2900
2901 cf::face::set_type $idx, $info->{type};
2902
2890 cf::cede_to_tick; 2903 cf::cede_to_tick;
2891 } 2904 }
2905
2906 if ($soundconf) {
2907 $soundconf = $enc->decode (delete $soundconf->{data});
2908
2909 for (0 .. SOUND_CAST_SPELL_0 - 1) {
2910 my $sound = $soundconf->{compat}[$_]
2911 or next;
2912
2913 my $face = cf::face::find "sound/$sound->[1]";
2914 cf::sound::set $sound->[0] => $face;
2915 cf::sound::old_sound_index $_, $face; # gcfclient-compat
2916 }
2917
2918 while (my ($k, $v) = each %{$soundconf->{event}}) {
2919 my $face = cf::face::find "sound/$v";
2920 cf::sound::set $k => $face;
2921 }
2922 }
2892 } 2923 }
2893 2924
2894 1 2925 1
2895} 2926}
2927
2928register_exticmd fx_want => sub {
2929 my ($ns, $want) = @_;
2930
2931 while (my ($k, $v) = each %$want) {
2932 $ns->fx_want ($k, $v);
2933 }
2934};
2896 2935
2897sub reload_regions { 2936sub reload_regions {
2898 load_resource_file "$MAPDIR/regions" 2937 load_resource_file "$MAPDIR/regions"
2899 or die "unable to load regions file\n"; 2938 or die "unable to load regions file\n";
2900 2939

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines