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.320 by root, Tue Jul 24 22:49:40 2007 UTC vs.
Revision 1.328 by root, Wed Aug 8 06:24:30 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")
2698our $safe = new Safe "safe"; 2710our $safe = new Safe "safe";
2699our $safe_hole = new Safe::Hole; 2711our $safe_hole = new Safe::Hole;
2700 2712
2701$SIG{FPE} = 'IGNORE'; 2713$SIG{FPE} = 'IGNORE';
2702 2714
2703$safe->permit_only (Opcode::opset qw(:base_core :base_mem :base_orig :base_math sort time)); 2715$safe->permit_only (Opcode::opset qw(
2716 :base_core :base_mem :base_orig :base_math
2717 grepstart grepwhile mapstart mapwhile
2718 sort time
2719));
2704 2720
2705# here we export the classes and methods available to script code 2721# here we export the classes and methods available to script code
2706 2722
2707=pod 2723=pod
2708 2724
2723 2739
2724=cut 2740=cut
2725 2741
2726for ( 2742for (
2727 ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y 2743 ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y
2728 insert remove)], 2744 insert remove inv)],
2729 ["cf::object::player" => qw(player)], 2745 ["cf::object::player" => qw(player)],
2730 ["cf::player" => qw(peaceful)], 2746 ["cf::player" => qw(peaceful)],
2731 ["cf::map" => qw(trigger)], 2747 ["cf::map" => qw(trigger)],
2732) { 2748) {
2733 no strict 'refs'; 2749 no strict 'refs';
2865 # TODO: for gcfclient pleasure, we should give resources 2881 # TODO: for gcfclient pleasure, we should give resources
2866 # that gcfclient doesn't grok a >10000 face index. 2882 # that gcfclient doesn't grok a >10000 face index.
2867 my $res = $facedata->{resource}; 2883 my $res = $facedata->{resource};
2868 my $enc = JSON::XS->new->utf8->canonical; 2884 my $enc = JSON::XS->new->utf8->canonical;
2869 2885
2870 if (my $soundconf = delete $res->{"res/sound.conf"}) { 2886 my $soundconf = delete $res->{"res/sound.conf"};
2871 $soundconf = $enc->decode (delete $soundconf->{data});
2872 # todo
2873 }
2874 2887
2875 while (my ($name, $info) = each %$res) { 2888 while (my ($name, $info) = each %$res) {
2876 my $meta = $enc->encode ({ 2889 my $meta = $enc->encode ({
2877 name => $name, 2890 name => $name,
2878 %{ $info->{meta} || {} }, 2891 %{ $info->{meta} || {} },
2892 } 2905 }
2893 2906
2894 cf::face::set_type $idx, $info->{type}; 2907 cf::face::set_type $idx, $info->{type};
2895 2908
2896 cf::cede_to_tick; 2909 cf::cede_to_tick;
2910 }
2911
2912 if ($soundconf) {
2913 $soundconf = $enc->decode (delete $soundconf->{data});
2914
2915 for (0 .. SOUND_CAST_SPELL_0 - 1) {
2916 my $sound = $soundconf->{compat}[$_]
2917 or next;
2918
2919 my $face = cf::face::find "sound/$sound->[1]";
2920 cf::sound::set $sound->[0] => $face;
2921 cf::sound::old_sound_index $_, $face; # gcfclient-compat
2922 }
2923
2924 while (my ($k, $v) = each %{$soundconf->{event}}) {
2925 my $face = cf::face::find "sound/$v";
2926 cf::sound::set $k => $face;
2927 }
2897 } 2928 }
2898 } 2929 }
2899 2930
2900 1 2931 1
2901} 2932}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines