--- deliantra/Deliantra-Client/DC.pm 2007/12/26 21:03:21 1.169 +++ deliantra/Deliantra-Client/DC.pm 2008/09/02 16:25:27 1.187 @@ -12,18 +12,23 @@ =cut +package Deliantra::Client; # work around CPAN breakage +package App::Deliantra; # try to reserve namespace package DC; use Carp (); +our $VERSION; + BEGIN { - $VERSION = '0.9962'; + $VERSION = '0.9975'; use XSLoader; XSLoader::load "Deliantra::Client", $VERSION; } use utf8; +use strict qw(vars subs); use AnyEvent (); use Pod::POM (); @@ -142,15 +147,24 @@ package DC; +our $RC_THEME = "."; +our $RC_BASE; + +for (grep !ref, @INC) { + $RC_BASE = "$_/Deliantra/Client/private/resources"; + last if -d $RC_BASE; +} + sub find_rcfile($) { my $path; - for (grep !ref, @INC) { - $path = "$_/Deliantra/Client/private/resources/$_[0]"; - return $path if -r $path; - } + $path = "$RC_BASE/$RC_THEME/$_[0]"; + return $path if -r $path; + + $path = "$RC_BASE/$_[0]"; + return $path if -r $path; - die "FATAL: can't find required file $_[0]\n"; + die "FATAL: can't find required file \"$_[0]\" in \"$RC_BASE\"\n"; } sub read_cfg { @@ -166,13 +180,13 @@ } sub write_cfg { - my ($file) = @_; + my $file = "$Deliantra::VARDIR/client.cf"; $::CFG->{VERSION} = $::VERSION; open my $fh, ">:utf8", $file or return; - print $fh encode_json $::CFG; + print $fh JSON::XS->new->utf8->pretty->encode ($::CFG); } sub http_proxy { @@ -200,7 +214,7 @@ DC::set_proxy; my $ua = LWP::UserAgent->new ( - agent => "cfplus $VERSION", + agent => "deliantra $VERSION", keep_alive => 1, env_proxy => 1, timeout => 30, @@ -225,7 +239,6 @@ } else { fcntl $fh, &Fcntl::F_SETFL, $nb ? &Fcntl::O_NONBLOCK : 0; } - } package DC::Layout;