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.106 by root, Mon Jul 24 04:24:42 2006 UTC vs.
Revision 1.107 by root, Mon Jul 24 08:23:27 2006 UTC

26use Carp (); 26use Carp ();
27use AnyEvent (); 27use AnyEvent ();
28use BerkeleyDB; 28use BerkeleyDB;
29use Pod::POM (); 29use Pod::POM ();
30use Scalar::Util (); 30use Scalar::Util ();
31use YAML ();
31use Storable (); # finally 32use Storable (); # finally
32 33
33our %STAT_TOOLTIP = ( 34our %STAT_TOOLTIP = (
34 Str => "<b>Physical Strength</b>, determines damage dealt with weapons, how much you can carry, and how often you can attack", 35 Str => "<b>Physical Strength</b>, determines damage dealt with weapons, how much you can carry, and how often you can attack",
35 Dex => "<b>Dexterity</b>, your physical agility. Determines chance of being hit and affects armor class and speed", 36 Dex => "<b>Dexterity</b>, your physical agility. Determines chance of being hit and affects armor class and speed",
104 } 105 }
105 106
106 die "FATAL: can't find required file $_[0]\n"; 107 die "FATAL: can't find required file $_[0]\n";
107} 108}
108 109
110sub parse_yaml {
111 my $text = shift;
112
113 utf8::decode $text;
114
115 YAML::Load $text
116}
117
109sub read_cfg { 118sub read_cfg {
110 my ($file) = @_; 119 my ($file) = @_;
111 120
112 open CFG, $file 121 open my $fh, $file
113 or return; 122 or return;
114 123
115 my $CFG;
116
117 local $/; 124 local $/;
118 $CFG = eval <CFG>; 125 my $CFG = <$fh>;
119 126
127 if ($CFG =~ /^---/) {
128 $::CFG = parse_yaml $CFG;
129 } else {
120 $::CFG = $CFG; 130 $::CFG = eval $CFG;
121 131 }
122 close CFG;
123} 132}
124 133
125sub write_cfg { 134sub write_cfg {
126 my ($file) = @_; 135 my ($file) = @_;
127 136
128 open CFG, ">$file" 137 $::CFG->{VERSION} = $::VERSION;
138
139 open my $fh, ">:utf8", $file
129 or return; 140 or return;
130 141 print $fh YAML::Dump $::CFG;
131 {
132 require Data::Dumper;
133 local $Data::Dumper::Purity = 1;
134 $::CFG->{VERSION} = $::VERSION;
135 print CFG Data::Dumper->Dump ([$::CFG], [qw/CFG/]);
136 }
137
138 close CFG;
139} 142}
140 143
141our $DB_ENV; 144our $DB_ENV;
142 145
143{ 146{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines