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.116 by root, Fri Aug 18 01:01:00 2006 UTC vs.
Revision 1.122 by root, Sun Oct 1 14:48:50 2006 UTC

12 12
13=cut 13=cut
14 14
15package CFPlus; 15package CFPlus;
16 16
17use Carp ();
18
17BEGIN { 19BEGIN {
18 $VERSION = '0.2'; 20 $VERSION = '0.52';
19 21
20 use XSLoader; 22 use XSLoader;
21 XSLoader::load "CFPlus", $VERSION; 23 XSLoader::load "CFPlus", $VERSION;
22} 24}
23 25
26BEGIN {
27 $SIG{__DIE__} = sub {
28 return if CFPlus::in_destruct;
29 #CFPlus::fatal $_[0];#d#
30 CFPlus::error Carp::longmess $_[0];#d#
31 die;#d#
32 };
33}
34
24use utf8; 35use utf8;
25 36
26use Carp ();
27use AnyEvent (); 37use AnyEvent ();
28use BerkeleyDB; 38use BerkeleyDB;
29use Pod::POM (); 39use Pod::POM ();
30use Scalar::Util (); 40use Scalar::Util ();
31use Storable (); # finally 41use Storable (); # finally
69my %DB_SYNC; 79my %DB_SYNC;
70 80
71sub put($$$) { 81sub put($$$) {
72 my ($db, $key, $data) = @_; 82 my ($db, $key, $data) = @_;
73 83
74 my $key = $db + 0; 84 my $hkey = $db + 0;
75 Scalar::Util::weaken $db; 85 Scalar::Util::weaken $db;
76 $DB_SYNC{$key} ||= AnyEvent->timer (after => 5, cb => sub { 86 $DB_SYNC{$hkey} ||= AnyEvent->timer (after => 5, cb => sub {
77 delete $DB_SYNC{$key}; 87 delete $DB_SYNC{$hkey};
78 $db->db_sync if $db; 88 $db->db_sync if $db;
79 }); 89 });
80 90
81 $db->db_put ($key => $data) 91 $db->db_put ($key => $data)
82} 92}
128 open my $fh, ">:utf8", $file 138 open my $fh, ">:utf8", $file
129 or return; 139 or return;
130 print $fh to_json $::CFG; 140 print $fh to_json $::CFG;
131} 141}
132 142
143sub http_proxy {
144 my @proxy = win32_proxy_info;
145
146 if (@proxy) {
147 "http://" . (@proxy < 2 ? "" : @proxy < 3 ? "$proxy[1]\@" : "$proxy[1]:$proxy[2]\@") . $proxy[0]
148 } elsif (exists $ENV{http_proxy}) {
149 $ENV{http_proxy}
150 } else {
151 ()
152 }
153}
154
155sub set_proxy {
156 my $proxy = http_proxy
157 or return;
158
159 $ENV{http_proxy} = $proxy;
160}
161
133our $DB_ENV; 162our $DB_ENV;
163our $DB_STATE;
164
165sub db_table($) {
166 my ($table) = @_;
167
168 $table =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge;
169
170 new CFPlus::Database
171 -Env => $DB_ENV,
172 -Filename => $table,
173# -Filename => "database",
174# -Subname => $table,
175 -Property => DB_CHKSUM,
176 -Flags => DB_CREATE | DB_UPGRADE,
177 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error"
178}
134 179
135{ 180{
136 use strict; 181 use strict;
137 182
138 mkdir "$Crossfire::VARDIR/cfplus", 0777; 183 mkdir "$Crossfire::VARDIR/cfplus", 0777;
147# -ErrPrefix => "DATABASE", 192# -ErrPrefix => "DATABASE",
148 -Verbose => 1, 193 -Verbose => 1,
149 -Flags => DB_CREATE | DB_RECOVER | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN | $recover, 194 -Flags => DB_CREATE | DB_RECOVER | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN | $recover,
150 -SetFlags => DB_AUTO_COMMIT | DB_LOG_AUTOREMOVE, 195 -SetFlags => DB_AUTO_COMMIT | DB_LOG_AUTOREMOVE,
151 or die "unable to create/open database home $Crossfire::VARDIR/cfplus: $BerkeleyDB::Error"; 196 or die "unable to create/open database home $Crossfire::VARDIR/cfplus: $BerkeleyDB::Error";
152}
153 197
154sub db_table($) { 198 $DB_STATE = db_table "state";
155 my ($table) = @_;
156
157 $table =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge;
158
159 new CFPlus::Database
160 -Env => $DB_ENV,
161 -Filename => $table,
162# -Filename => "database",
163# -Subname => $table,
164 -Property => DB_CHKSUM,
165 -Flags => DB_CREATE | DB_UPGRADE,
166 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error"
167} 199}
168 200
169package CFPlus::Layout; 201package CFPlus::Layout;
170 202
171$CFPlus::OpenGL::SHUTDOWN_HOOK{"CFPlus::Layout"} = sub { 203$CFPlus::OpenGL::SHUTDOWN_HOOK{"CFPlus::Layout"} = sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines