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.287 by root, Mon Jun 25 05:43:45 2007 UTC vs.
Revision 1.289 by root, Sat Jun 30 03:00:54 2007 UTC

20use Coro::Signal; 20use Coro::Signal;
21use Coro::Semaphore; 21use Coro::Semaphore;
22use Coro::AIO; 22use Coro::AIO;
23use Coro::Storable; 23use Coro::Storable;
24 24
25use JSON::XS 1.4 ();
25use BDB (); 26use BDB ();
26use Data::Dumper; 27use Data::Dumper;
27use Digest::MD5; 28use Digest::MD5;
28use Fcntl; 29use Fcntl;
29use YAML::Syck (); 30use YAML::Syck ();
237 $d =~ s/([\x00-\x07\x09\x0b\x0c\x0e-\x1f])/sprintf "\\x%02x", ord($1)/ge; 238 $d =~ s/([\x00-\x07\x09\x0b\x0c\x0e-\x1f])/sprintf "\\x%02x", ord($1)/ge;
238 $d 239 $d
239 } || "[unable to dump $_[0]: '$@']"; 240 } || "[unable to dump $_[0]: '$@']";
240} 241}
241 242
242use JSON::XS ();
243
244=item $ref = cf::from_json $json 243=item $ref = cf::from_json $json
245 244
246Converts a JSON string into the corresponding perl data structure. 245Converts a JSON string into the corresponding perl data structure.
247 246
248=item $json = cf::to_json $ref 247=item $json = cf::to_json $ref
249 248
250Converts a perl data structure into its JSON representation. 249Converts a perl data structure into its JSON representation.
251 250
252=cut 251=cut
253 252
254our $json_coder = JSON::XS->new->convert_blessed->utf8; 253our $json_coder = JSON::XS->new->convert_blessed->utf8->max_size (1e6); # accept ~1mb max
255 254
256sub to_json ($) { $json_coder->encode ($_[0]) } 255sub to_json ($) { $json_coder->encode ($_[0]) }
257sub from_json ($) { $json_coder->decode ($_[0]) } 256sub from_json ($) { $json_coder->decode ($_[0]) }
258 257
259=item cf::lock_wait $string 258=item cf::lock_wait $string
2711} 2710}
2712 2711
2713sub reload_archetypes { 2712sub reload_archetypes {
2714 load_resource_file "$DATADIR/archetypes" 2713 load_resource_file "$DATADIR/archetypes"
2715 or die "unable to load archetypes\n"; 2714 or die "unable to load archetypes\n";
2715 #d# NEED to laod twice to resolve forward references
2716 # this really needs to be done in an extra post-pass
2717 # (which needs to be synchronous, so solve it differently)
2718 load_resource_file "$DATADIR/archetypes"
2719 or die "unable to load archetypes\n";
2716} 2720}
2717 2721
2718sub reload_treasures { 2722sub reload_treasures {
2719 load_resource_file "$DATADIR/treasures" 2723 load_resource_file "$DATADIR/treasures"
2720 or die "unable to load treasurelists\n"; 2724 or die "unable to load treasurelists\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines