--- deliantra/Deliantra-Client/DC.pm 2012/01/18 00:51:22 1.214 +++ deliantra/Deliantra-Client/DC.pm 2012/11/17 10:40:08 1.216 @@ -44,6 +44,7 @@ use Coro::AIO (); use AnyEvent::AIO (); +use Deliantra::Util (); use Deliantra::Protocol::Constants (); =item shorten $string[, $maxlength] @@ -189,13 +190,13 @@ } } -sub read_cfg { +sub read_cfg($) { my ($file) = @_; $::CFG = (load_json $file) || (load_json "$file.bak"); } -sub write_cfg { +sub write_cfg($) { my $file = "$Deliantra::VARDIR/client.cf"; $::CFG->{VERSION} = $::VERSION; @@ -210,6 +211,18 @@ rename "$file~", $file; } +sub load_cfg() { + if (-e "$Deliantra::VARDIR/client.cf") { + DC::read_cfg "$Deliantra::VARDIR/client.cf"; + } else { + $::CFG = { cfg_schema => 1, db_schema => 1 }; + } +} + +sub save_cfg() { + write_cfg "$Deliantra::VARDIR/client.cf"; +} + sub upgrade_cfg() { my %DEF_CFG = ( config_autosave => 1, @@ -253,12 +266,18 @@ uitheme => "wood", map_shift_x => -24, # arbitrary map_shift_y => +24, # arbitrary - #db_schema => 0, ); while (my ($k, $v) = each %DEF_CFG) { $::CFG->{$k} = $v unless exists $::CFG->{$k}; } + + if ($::CFG->{cfg_schema} < 1) { + for my $profile (values %{ $::CFG->{profile} }) { + $profile->{password} = unpack "H*", Deliantra::Util::hash_pw $profile->{password}; + } + $::CFG->{cfg_schema} = 1; + } } sub http_proxy {