--- deliantra/Deliantra-Client/DC.pm 2007/09/02 08:44:28 1.151 +++ deliantra/Deliantra-Client/DC.pm 2008/03/30 04:59:41 1.177 @@ -1,10 +1,10 @@ =head1 NAME -CFPlus - undocumented utility garbage for our crossfire client +DC - undocumented utility garbage for our deliantra client =head1 SYNOPSIS - use CFPlus; + use DC; =head1 DESCRIPTION @@ -12,15 +12,15 @@ =cut -package CFPlus; +package DC; use Carp (); BEGIN { - $VERSION = '0.99'; + $VERSION = '0.9969'; use XSLoader; - XSLoader::load "CFPlus", $VERSION; + XSLoader::load "Deliantra::Client", $VERSION; } use utf8; @@ -30,7 +30,7 @@ use File::Path (); use Storable (); # finally use Fcntl (); -use JSON::XS qw(to_json from_json); +use JSON::XS qw(encode_json decode_json); =item guard { BLOCK } @@ -39,10 +39,10 @@ =cut sub guard(&) { - bless \(my $cb = $_[0]), "CFPlus::Guard" + bless \(my $cb = $_[0]), "DC::Guard" } -sub CFPlus::Guard::DESTROY { +sub DC::Guard::DESTROY { ${$_[0]}->() } @@ -76,7 +76,7 @@ sub background(&;&) { my ($bg, $cb) = @_; - my ($fh_r, $fh_w) = CFPlus::socketpipe; + my ($fh_r, $fh_w) = DC::socketpipe; my $pid = fork; @@ -96,13 +96,13 @@ my $msg = $@; $msg =~ s/\n+/\n/; warn "FATAL: $msg"; - CFPlus::_exit 1; + DC::_exit 1; } # win32 is fucked up, of course. exit will clean stuff up, # which destroys our database etc. _exit will exit ALL # forked processes, because of the dreaded fork emulation. - CFPlus::_exit 0; + DC::_exit 0; } close $fh_w; @@ -124,7 +124,7 @@ $cb->(JSON::XS->new->allow_nonref->decode ($1)); } else { ::message ({ - markup => "background($pid): " . CFPlus::asxml $line, + markup => "background($pid): " . DC::asxml $line, }); } } @@ -140,13 +140,13 @@ print $msg, "\n"; } -package CFPlus; +package DC; sub find_rcfile($) { my $path; for (grep !ref, @INC) { - $path = "$_/CFPlus/resources/$_[0]"; + $path = "$_/Deliantra/Client/private/resources/$_[0]"; return $path if -r $path; } @@ -162,15 +162,7 @@ local $/; my $CFG = <$fh>; - if ($CFG =~ /^---/) { ## TODO compatibility cruft, remove - require YAML; - utf8::decode $CFG; - $::CFG = YAML::Load ($CFG); - } elsif ($CFG =~ /^\{/) { - $::CFG = from_json $CFG; - } else { - $::CFG = eval $CFG; ## todo comaptibility cruft - } + $::CFG = decode_json $CFG; } sub write_cfg { @@ -180,7 +172,7 @@ open my $fh, ">:utf8", $file or return; - print $fh to_json $::CFG; + print $fh encode_json $::CFG; } sub http_proxy { @@ -205,10 +197,10 @@ sub lwp_useragent { require LWP::UserAgent; - CFPlus::set_proxy; + DC::set_proxy; my $ua = LWP::UserAgent->new ( - agent => "cfplus $VERSION", + agent => "deliantra $VERSION", keep_alive => 1, env_proxy => 1, timeout => 30, @@ -236,10 +228,14 @@ } -package CFPlus::Layout; +package DC::Layout; + +$DC::OpenGL::INIT_HOOK{"DC::Layout"} = sub { + glyph_cache_restore; +}; -$CFPlus::OpenGL::SHUTDOWN_HOOK{"CFPlus::Layout"} = sub { - reset_glyph_cache; +$DC::OpenGL::SHUTDOWN_HOOK{"DC::Layout"} = sub { + glyph_cache_backup; }; 1;