ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.214 by root, Wed Jan 18 00:51:22 2012 UTC vs.
Revision 1.216 by root, Sat Nov 17 10:40:08 2012 UTC

42use List::Util (); 42use List::Util ();
43use IO::AIO (); 43use IO::AIO ();
44use Coro::AIO (); 44use Coro::AIO ();
45use AnyEvent::AIO (); 45use AnyEvent::AIO ();
46 46
47use Deliantra::Util ();
47use Deliantra::Protocol::Constants (); 48use Deliantra::Protocol::Constants ();
48 49
49=item shorten $string[, $maxlength] 50=item shorten $string[, $maxlength]
50 51
51=cut 52=cut
187 188
188 %THEME = ( %$theme, %THEME ); 189 %THEME = ( %$theme, %THEME );
189 } 190 }
190} 191}
191 192
192sub read_cfg { 193sub read_cfg($) {
193 my ($file) = @_; 194 my ($file) = @_;
194 195
195 $::CFG = (load_json $file) || (load_json "$file.bak"); 196 $::CFG = (load_json $file) || (load_json "$file.bak");
196} 197}
197 198
198sub write_cfg { 199sub write_cfg($) {
199 my $file = "$Deliantra::VARDIR/client.cf"; 200 my $file = "$Deliantra::VARDIR/client.cf";
200 201
201 $::CFG->{VERSION} = $::VERSION; 202 $::CFG->{VERSION} = $::VERSION;
202 $::CFG->{layout} = DC::UI::get_layout (); 203 $::CFG->{layout} = DC::UI::get_layout ();
203 204
206 print $fh JSON::XS->new->utf8->pretty->encode ($::CFG); 207 print $fh JSON::XS->new->utf8->pretty->encode ($::CFG);
207 close $fh; 208 close $fh;
208 209
209 rename $file, "$file.bak"; 210 rename $file, "$file.bak";
210 rename "$file~", $file; 211 rename "$file~", $file;
212}
213
214sub load_cfg() {
215 if (-e "$Deliantra::VARDIR/client.cf") {
216 DC::read_cfg "$Deliantra::VARDIR/client.cf";
217 } else {
218 $::CFG = { cfg_schema => 1, db_schema => 1 };
219 }
220}
221
222sub save_cfg() {
223 write_cfg "$Deliantra::VARDIR/client.cf";
211} 224}
212 225
213sub upgrade_cfg() { 226sub upgrade_cfg() {
214 my %DEF_CFG = ( 227 my %DEF_CFG = (
215 config_autosave => 1, 228 config_autosave => 1,
251 logview_max_par => 1000, 264 logview_max_par => 1000,
252 shift_fire_stop => 0, 265 shift_fire_stop => 0,
253 uitheme => "wood", 266 uitheme => "wood",
254 map_shift_x => -24, # arbitrary 267 map_shift_x => -24, # arbitrary
255 map_shift_y => +24, # arbitrary 268 map_shift_y => +24, # arbitrary
256 #db_schema => 0,
257 ); 269 );
258 270
259 while (my ($k, $v) = each %DEF_CFG) { 271 while (my ($k, $v) = each %DEF_CFG) {
260 $::CFG->{$k} = $v unless exists $::CFG->{$k}; 272 $::CFG->{$k} = $v unless exists $::CFG->{$k};
273 }
274
275 if ($::CFG->{cfg_schema} < 1) {
276 for my $profile (values %{ $::CFG->{profile} }) {
277 $profile->{password} = unpack "H*", Deliantra::Util::hash_pw $profile->{password};
278 }
279 $::CFG->{cfg_schema} = 1;
261 } 280 }
262} 281}
263 282
264sub http_proxy { 283sub http_proxy {
265 my @proxy = win32_proxy_info; 284 my @proxy = win32_proxy_info;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines