… | |
… | |
371 | |
371 | |
372 | aio_rename "$runtime~", $runtime |
372 | aio_rename "$runtime~", $runtime |
373 | and return; |
373 | and return; |
374 | |
374 | |
375 | 1 |
375 | 1 |
|
|
376 | } |
|
|
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 }); |
376 | } |
387 | } |
377 | |
388 | |
378 | =back |
389 | =back |
379 | |
390 | |
380 | =cut |
391 | =cut |
… | |
… | |
2093 | |
2104 | |
2094 | # here we export the classes and methods available to script code |
2105 | # here we export the classes and methods available to script code |
2095 | |
2106 | |
2096 | =pod |
2107 | =pod |
2097 | |
2108 | |
2098 | The following fucntions and emthods are available within a safe environment: |
2109 | The following functions and methods are available within a safe environment: |
2099 | |
2110 | |
2100 | cf::object contr pay_amount pay_player map |
2111 | cf::object contr pay_amount pay_player map |
2101 | cf::object::player player |
2112 | cf::object::player player |
2102 | cf::player peaceful |
2113 | cf::player peaceful |
2103 | cf::map trigger |
2114 | cf::map trigger |
… | |
… | |
2258 | } |
2269 | } |
2259 | |
2270 | |
2260 | ############################################################################# |
2271 | ############################################################################# |
2261 | # the server's init and main functions |
2272 | # the server's init and main functions |
2262 | |
2273 | |
2263 | sub load_faces { |
2274 | sub load_facedata { |
2264 | my $path = sprintf "%s/faces", cf::datadir; |
2275 | my $path = sprintf "%s/facedata", cf::datadir; |
2265 | |
2276 | |
2266 | warn "loading faces from $path\n"; |
2277 | warn "loading facedata from $path\n"; |
2267 | |
2278 | |
2268 | my $faces; |
2279 | my $faces; |
2269 | 0 < aio_load $path, $faces |
2280 | 0 < aio_load $path, $faces |
2270 | or die "$path: $!"; |
2281 | or die "$path: $!"; |
2271 | |
2282 | |
… | |
… | |
2279 | |
2290 | |
2280 | while (my ($face, $info) = each %$faces) { |
2291 | while (my ($face, $info) = each %$faces) { |
2281 | my $idx = (cf::face::find $face) || cf::face::alloc $face; |
2292 | my $idx = (cf::face::find $face) || cf::face::alloc $face; |
2282 | cf::face::set $idx, $info->{visibility}, $info->{magicmap}; |
2293 | cf::face::set $idx, $info->{visibility}, $info->{magicmap}; |
2283 | cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; |
2294 | cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; |
|
|
2295 | cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64}; |
2284 | Coro::cede; |
2296 | Coro::cede; |
2285 | } |
2297 | } |
2286 | |
2298 | |
2287 | while (my ($face, $info) = each %$faces) { |
2299 | while (my ($face, $info) = each %$faces) { |
2288 | next unless $info->{smooth}; |
2300 | next unless $info->{smooth}; |
… | |
… | |
2300 | } |
2312 | } |
2301 | |
2313 | |
2302 | sub reload_resources { |
2314 | sub reload_resources { |
2303 | load_resource_file sprintf "%s/%s/regions", cf::datadir, cf::mapdir |
2315 | load_resource_file sprintf "%s/%s/regions", cf::datadir, cf::mapdir |
2304 | or die "unable to load regions file\n";#d# |
2316 | or die "unable to load regions file\n";#d# |
2305 | load_faces |
2317 | load_facedata |
2306 | or die "unable to load faces\n";#d# |
2318 | or die "unable to load facedata\n";#d# |
2307 | } |
2319 | } |
2308 | |
2320 | |
2309 | sub init { |
2321 | sub init { |
2310 | reload_resources; |
2322 | reload_resources; |
2311 | } |
2323 | } |