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.140 by root, Fri Apr 6 07:45:33 2007 UTC vs.
Revision 1.166 by root, Wed Dec 26 18:20:45 2007 UTC

15package CFPlus; 15package CFPlus;
16 16
17use Carp (); 17use Carp ();
18 18
19BEGIN { 19BEGIN {
20 $VERSION = '0.97'; 20 $VERSION = '0.9961';
21 21
22 use XSLoader; 22 use XSLoader;
23 XSLoader::load "CFPlus", $VERSION; 23 XSLoader::load "CFPlus", $VERSION;
24} 24}
25 25
27 27
28use AnyEvent (); 28use AnyEvent ();
29use Pod::POM (); 29use Pod::POM ();
30use File::Path (); 30use File::Path ();
31use Storable (); # finally 31use Storable (); # finally
32 32use Fcntl ();
33BEGIN { 33use JSON::XS qw(encode_json decode_json);
34 use Crossfire::Protocol::Base ();
35 *to_json = \&Crossfire::Protocol::Base::to_json;
36 *from_json = \&Crossfire::Protocol::Base::from_json;
37}
38 34
39=item guard { BLOCK } 35=item guard { BLOCK }
40 36
41Returns an object that executes the given block as soon as it is destroyed. 37Returns an object that executes the given block as soon as it is destroyed.
42 38
164 or return; 160 or return;
165 161
166 local $/; 162 local $/;
167 my $CFG = <$fh>; 163 my $CFG = <$fh>;
168 164
169 if ($CFG =~ /^---/) { ## TODO compatibility cruft, remove
170 require YAML;
171 utf8::decode $CFG;
172 $::CFG = YAML::Load ($CFG);
173 } elsif ($CFG =~ /^\{/) {
174 $::CFG = from_json $CFG; 165 $::CFG = decode_json $CFG;
175 } else {
176 $::CFG = eval $CFG; ## todo comaptibility cruft
177 }
178} 166}
179 167
180sub write_cfg { 168sub write_cfg {
181 my ($file) = @_; 169 my ($file) = @_;
182 170
183 $::CFG->{VERSION} = $::VERSION; 171 $::CFG->{VERSION} = $::VERSION;
184 172
185 open my $fh, ">:utf8", $file 173 open my $fh, ">:utf8", $file
186 or return; 174 or return;
187 print $fh to_json $::CFG; 175 print $fh encode_json $::CFG;
188} 176}
189 177
190sub http_proxy { 178sub http_proxy {
191 my @proxy = win32_proxy_info; 179 my @proxy = win32_proxy_info;
192 180
226 and die $res->status_line; 214 and die $res->status_line;
227 215
228 $res 216 $res
229} 217}
230 218
219sub fh_nonblocking($$) {
220 my ($fh, $nb) = @_;
221
222 if ($^O eq "MSWin32") {
223 $nb = (! ! $nb) + 0;
224 ioctl $fh, 0x8004667e, \$nb; # FIONBIO
225 } else {
226 fcntl $fh, &Fcntl::F_SETFL, $nb ? &Fcntl::O_NONBLOCK : 0;
227 }
228
229}
230
231package CFPlus::Layout; 231package CFPlus::Layout;
232 232
233$CFPlus::OpenGL::INIT_HOOK{"CFPlus::Layout"} = sub {
234 glyph_cache_restore;
235};
236
233$CFPlus::OpenGL::SHUTDOWN_HOOK{"CFPlus::Layout"} = sub { 237$CFPlus::OpenGL::SHUTDOWN_HOOK{"CFPlus::Layout"} = sub {
234 reset_glyph_cache; 238 glyph_cache_backup;
235}; 239};
236 240
2371; 2411;
238 242
239=back 243=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines