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.227 by root, Fri Mar 23 18:32:48 2007 UTC vs.
Revision 1.233 by root, Wed Apr 4 02:20:27 2007 UTC

373 and return; 373 and return;
374 374
375 1 375 1
376} 376}
377 377
378=item cf::datalog type => key => value, ...
379
380Log a datalog packet of the given type with the given key-value pairs.
381
382=cut
383
384sub datalog($@) {
385 my ($type, %kv) = @_;
386 warn "DATALOG ", JSON::XS->new->ascii->encode ({ %kv, type => $type });
387}
388
378=back 389=back
379 390
380=cut 391=cut
381 392
382############################################################################# 393#############################################################################
1113 } 1124 }
1114 1125
1115 \@paths 1126 \@paths
1116} 1127}
1117 1128
1118=item $player->ext_reply ($msgid, $msgtype, %msg) 1129=item $player->ext_reply ($msgid, %msg)
1119 1130
1120Sends an ext reply to the player. 1131Sends an ext reply to the player.
1121 1132
1122=cut 1133=cut
1123 1134
1124sub ext_reply($$$%) { 1135sub ext_reply($$%) {
1125 my ($self, $id, %msg) = @_; 1136 my ($self, $id, %msg) = @_;
1126 1137
1127 $msg{msgid} = $id; 1138 $msg{msgid} = $id;
1128 1139
1129 $self->send ("ext " . cf::to_json \%msg); 1140 $self->send ("ext " . cf::to_json \%msg);
1141}
1142
1143=item $player->ext_event ($type, %msg)
1144
1145Sends an ext event to the client.
1146
1147=cut
1148
1149sub ext_event($$%) {
1150 my ($self, $type, %msg) = @_;
1151
1152 $self->ns->ext_event ($type, %msg);
1130} 1153}
1131 1154
1132package cf; 1155package cf;
1133 1156
1134=back 1157=back
1942 1965
1943 return unless $self->type == cf::PLAYER; 1966 return unless $self->type == cf::PLAYER;
1944 1967
1945 if ($exit->slaying eq "/!") { 1968 if ($exit->slaying eq "/!") {
1946 #TODO: this should de-fi-ni-te-ly not be a sync-job 1969 #TODO: this should de-fi-ni-te-ly not be a sync-job
1970 # the problem is that $exit might not survive long enough
1971 # so it needs to be done right now, right here
1947 cf::sync_job { prepare_random_map $exit }; 1972 cf::sync_job { prepare_random_map $exit };
1948 } 1973 }
1949 1974
1950 my $slaying = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path; 1975 my $slaying = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path;
1951 my $hp = $exit->stats->hp; 1976 my $hp = $exit->stats->hp;
1959 $self->goto ($slaying, $hp, $sp); 1984 $self->goto ($slaying, $hp, $sp);
1960 1985
1961 1; 1986 1;
1962 }) { 1987 }) {
1963 $self->message ("Something went wrong deep within the crossfire server. " 1988 $self->message ("Something went wrong deep within the crossfire server. "
1964 . "I'll try to bring you back to the map you were before. " 1989 . "I'll try to bring you back to the map you were before. "
1965 . "Please report this to the dungeon master!", 1990 . "Please report this to the dungeon master!",
1966 cf::NDI_UNIQUE | cf::NDI_RED); 1991 cf::NDI_UNIQUE | cf::NDI_RED);
1967 1992
1968 warn "ERROR in enter_exit: $@"; 1993 warn "ERROR in enter_exit: $@";
1969 $self->leave_link; 1994 $self->leave_link;
1970 } 1995 }
1971 })->prio (1); 1996 })->prio (1);
1987 2012
1988 utf8::encode $text; 2013 utf8::encode $text;
1989 $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text); 2014 $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text);
1990} 2015}
1991 2016
2017=item $client->ext_event ($type, %msg)
2018
2019Sends an exti event to the client.
2020
2021=cut
2022
2023sub cf::client::ext_event($$%) {
2024 my ($self, $type, %msg) = @_;
2025
2026 $msg{msgtype} = "event_$type";
2027 $self->send_packet ("ext " . cf::to_json \%msg);
2028}
1992 2029
1993=item $success = $client->query ($flags, "text", \&cb) 2030=item $success = $client->query ($flags, "text", \&cb)
1994 2031
1995Queues a query to the client, calling the given callback with 2032Queues a query to the client, calling the given callback with
1996the reply text on a reply. flags can be C<cf::CS_QUERY_YESNO>, 2033the reply text on a reply. flags can be C<cf::CS_QUERY_YESNO>,
2093 2130
2094# here we export the classes and methods available to script code 2131# here we export the classes and methods available to script code
2095 2132
2096=pod 2133=pod
2097 2134
2098The following fucntions and emthods are available within a safe environment: 2135The following functions and methods are available within a safe environment:
2099 2136
2100 cf::object contr pay_amount pay_player map 2137 cf::object contr pay_amount pay_player map
2101 cf::object::player player 2138 cf::object::player player
2102 cf::player peaceful 2139 cf::player peaceful
2103 cf::map trigger 2140 cf::map trigger
2258} 2295}
2259 2296
2260############################################################################# 2297#############################################################################
2261# the server's init and main functions 2298# the server's init and main functions
2262 2299
2263sub load_faces { 2300sub load_facedata {
2264 my $path = sprintf "%s/faces", cf::datadir; 2301 my $path = sprintf "%s/facedata", cf::datadir;
2265 2302
2266 warn "loading faces from $path\n"; 2303 warn "loading facedata from $path\n";
2267 2304
2268 my $faces; 2305 my $faces;
2269 0 < aio_load $path, $faces 2306 0 < aio_load $path, $faces
2270 or die "$path: $!"; 2307 or die "$path: $!";
2271 2308
2279 2316
2280 while (my ($face, $info) = each %$faces) { 2317 while (my ($face, $info) = each %$faces) {
2281 my $idx = (cf::face::find $face) || cf::face::alloc $face; 2318 my $idx = (cf::face::find $face) || cf::face::alloc $face;
2282 cf::face::set $idx, $info->{visibility}, $info->{magicmap}; 2319 cf::face::set $idx, $info->{visibility}, $info->{magicmap};
2283 cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; 2320 cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32};
2321 cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64};
2284 Coro::cede; 2322 Coro::cede;
2285 } 2323 }
2286 2324
2287 while (my ($face, $info) = each %$faces) { 2325 while (my ($face, $info) = each %$faces) {
2288 next unless $info->{smooth}; 2326 next unless $info->{smooth};
2300} 2338}
2301 2339
2302sub reload_resources { 2340sub reload_resources {
2303 load_resource_file sprintf "%s/%s/regions", cf::datadir, cf::mapdir 2341 load_resource_file sprintf "%s/%s/regions", cf::datadir, cf::mapdir
2304 or die "unable to load regions file\n";#d# 2342 or die "unable to load regions file\n";#d#
2305 load_faces 2343 load_facedata
2306 or die "unable to load faces\n";#d# 2344 or die "unable to load facedata\n";#d#
2307} 2345}
2308 2346
2309sub init { 2347sub init {
2310 reload_resources; 2348 reload_resources;
2311} 2349}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines