… | |
… | |
373 | and return; |
373 | and return; |
374 | |
374 | |
375 | 1 |
375 | 1 |
376 | } |
376 | } |
377 | |
377 | |
|
|
378 | =item cf::datalog type => key => value, ... |
|
|
379 | |
|
|
380 | Log a datalog packet of the given type with the given key-value pairs. |
|
|
381 | |
|
|
382 | =cut |
|
|
383 | |
|
|
384 | sub 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 | |
1120 | Sends an ext reply to the player. |
1131 | Sends an ext reply to the player. |
1121 | |
1132 | |
1122 | =cut |
1133 | =cut |
1123 | |
1134 | |
1124 | sub ext_reply($$$%) { |
1135 | sub 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 | |
|
|
1145 | Sends an ext event to the client. |
|
|
1146 | |
|
|
1147 | =cut |
|
|
1148 | |
|
|
1149 | sub ext_event($$%) { |
|
|
1150 | my ($self, $type, %msg) = @_; |
|
|
1151 | |
|
|
1152 | $self->ns->ext_event ($type, %msg); |
1130 | } |
1153 | } |
1131 | |
1154 | |
1132 | package cf; |
1155 | package cf; |
1133 | |
1156 | |
1134 | =back |
1157 | =back |
… | |
… | |
1987 | |
2010 | |
1988 | utf8::encode $text; |
2011 | utf8::encode $text; |
1989 | $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text); |
2012 | $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text); |
1990 | } |
2013 | } |
1991 | |
2014 | |
|
|
2015 | =item $client->ext_event ($type, %msg) |
|
|
2016 | |
|
|
2017 | Sends an exti event to the client. |
|
|
2018 | |
|
|
2019 | =cut |
|
|
2020 | |
|
|
2021 | sub cf::client::ext_event($$%) { |
|
|
2022 | my ($self, $type, %msg) = @_; |
|
|
2023 | |
|
|
2024 | $msg{msgtype} = "event_$type"; |
|
|
2025 | $self->send_packet ("ext " . cf::to_json \%msg); |
|
|
2026 | } |
1992 | |
2027 | |
1993 | =item $success = $client->query ($flags, "text", \&cb) |
2028 | =item $success = $client->query ($flags, "text", \&cb) |
1994 | |
2029 | |
1995 | Queues a query to the client, calling the given callback with |
2030 | Queues a query to the client, calling the given callback with |
1996 | the reply text on a reply. flags can be C<cf::CS_QUERY_YESNO>, |
2031 | the reply text on a reply. flags can be C<cf::CS_QUERY_YESNO>, |
… | |
… | |
2258 | } |
2293 | } |
2259 | |
2294 | |
2260 | ############################################################################# |
2295 | ############################################################################# |
2261 | # the server's init and main functions |
2296 | # the server's init and main functions |
2262 | |
2297 | |
2263 | sub load_faces { |
2298 | sub load_facedata { |
2264 | my $path = sprintf "%s/faces", cf::datadir; |
2299 | my $path = sprintf "%s/facedata", cf::datadir; |
2265 | |
2300 | |
2266 | warn "loading faces from $path\n"; |
2301 | warn "loading facedata from $path\n"; |
2267 | |
2302 | |
2268 | my $faces; |
2303 | my $faces; |
2269 | 0 < aio_load $path, $faces |
2304 | 0 < aio_load $path, $faces |
2270 | or die "$path: $!"; |
2305 | or die "$path: $!"; |
2271 | |
2306 | |
… | |
… | |
2279 | |
2314 | |
2280 | while (my ($face, $info) = each %$faces) { |
2315 | while (my ($face, $info) = each %$faces) { |
2281 | my $idx = (cf::face::find $face) || cf::face::alloc $face; |
2316 | my $idx = (cf::face::find $face) || cf::face::alloc $face; |
2282 | cf::face::set $idx, $info->{visibility}, $info->{magicmap}; |
2317 | cf::face::set $idx, $info->{visibility}, $info->{magicmap}; |
2283 | cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; |
2318 | cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; |
|
|
2319 | cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64}; |
2284 | Coro::cede; |
2320 | Coro::cede; |
2285 | } |
2321 | } |
2286 | |
2322 | |
2287 | while (my ($face, $info) = each %$faces) { |
2323 | while (my ($face, $info) = each %$faces) { |
2288 | next unless $info->{smooth}; |
2324 | next unless $info->{smooth}; |
… | |
… | |
2300 | } |
2336 | } |
2301 | |
2337 | |
2302 | sub reload_resources { |
2338 | sub reload_resources { |
2303 | load_resource_file sprintf "%s/%s/regions", cf::datadir, cf::mapdir |
2339 | load_resource_file sprintf "%s/%s/regions", cf::datadir, cf::mapdir |
2304 | or die "unable to load regions file\n";#d# |
2340 | or die "unable to load regions file\n";#d# |
2305 | load_faces |
2341 | load_facedata |
2306 | or die "unable to load faces\n";#d# |
2342 | or die "unable to load facedata\n";#d# |
2307 | } |
2343 | } |
2308 | |
2344 | |
2309 | sub init { |
2345 | sub init { |
2310 | reload_resources; |
2346 | reload_resources; |
2311 | } |
2347 | } |