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.32 by root, Tue Aug 15 18:07:25 2006 UTC vs.
Revision 1.33 by root, Mon Aug 21 01:51:23 2006 UTC

385}; 385};
386 386
387############################################################################# 387#############################################################################
388# load/save perl data associated with player->ob objects 388# load/save perl data associated with player->ob objects
389 389
390sub all_objects(@) {
391 @_, map all_objects ($_->inv), @_
392}
393
390*on_player_load = sub { 394*on_player_load = sub {
391 my ($ob, $path) = @_; 395 my ($ob, $path) = @_;
392 396
393 for my $o ($ob, $ob->inv) { 397 for my $o (all_objects $ob) {
394 if (my $value = $o->get_ob_key_value ("_perl_data")) { 398 if (my $value = $o->get_ob_key_value ("_perl_data")) {
395 $o->set_ob_key_value ("_perl_data"); 399 $o->set_ob_key_value ("_perl_data");
396 400
397 %$o = %{ Storable::thaw pack "H*", $value }; 401 %$o = %{ Storable::thaw pack "H*", $value };
398 } 402 }
401 405
402*on_player_save = sub { 406*on_player_save = sub {
403 my ($ob, $path) = @_; 407 my ($ob, $path) = @_;
404 408
405 $_->set_ob_key_value (_perl_data => unpack "H*", Storable::nfreeze $_) 409 $_->set_ob_key_value (_perl_data => unpack "H*", Storable::nfreeze $_)
406 for grep %$_, $ob, $ob->inv; 410 for grep %$_, all_objects $ob;
407}; 411};
408 412
409############################################################################# 413#############################################################################
410# core extensions - in perl 414# core extensions - in perl
411 415

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines