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.34 by root, Sat Apr 15 21:16:49 2006 UTC vs.
Revision 1.37 by root, Sun Apr 16 07:25:29 2006 UTC

117sub get($$) { 117sub get($$) {
118 my $data; 118 my $data;
119 119
120 $_[0]->db_get ($_[1], $data) == 0 120 $_[0]->db_get ($_[1], $data) == 0
121 ? $data 121 ? $data
122 : (); 122 : ()
123} 123}
124 124
125my %DB_SYNC; 125my %DB_SYNC;
126 126
127sub put($$$) { 127sub put($$$) {
128 my ($db, $key, $data) = @_; 128 my ($db, $key, $data) = @_;
129 129
130 $db->db_put ($key => $data);
131
132 $DB_SYNC{$db} = AnyEvent->timer (after => 5, cb => sub { $db->db_sync }); 130 $DB_SYNC{$db} = AnyEvent->timer (after => 5, cb => sub { $db->db_sync });
133 131
132 $db->db_put ($key => $data)
134} 133}
135 134
136package CFClient::Texture; 135package CFClient::Texture;
137 136
138use strict; 137use strict;
139 138
140use Scalar::Util; 139use Scalar::Util;
141 140
142use SDL::OpenGL; 141use SDL::OpenGL;
143 142
144my @textures; 143my %TEXTURES;
145 144
146sub new { 145sub new {
147 my ($class, %data) = @_; 146 my ($class, %data) = @_;
148 147
149 my $self = bless { 148 my $self = bless {
151 format => GL_RGBA, 150 format => GL_RGBA,
152 type => GL_UNSIGNED_BYTE, 151 type => GL_UNSIGNED_BYTE,
153 %data, 152 %data,
154 }, $class; 153 }, $class;
155 154
156 push @textures, $self; 155 Scalar::Util::weaken ($TEXTURES{$self+0} = $self);
157 Scalar::Util::weaken $textures[-1];
158 156
159 $self->upload; 157 $self->upload;
160 158
161 $self 159 $self
162} 160}
293} 291}
294 292
295sub DESTROY { 293sub DESTROY {
296 my ($self) = @_; 294 my ($self) = @_;
297 295
298 return unless exists $self->{name}; 296 delete $TEXTURES{$self+0};
299 297
300 glDeleteTextures delete $self->{name}; 298 glDeleteTextures delete $self->{name}
299 if $self->{name};
301} 300}
302 301
303sub restore_state{ 302sub restore_state{
304 $_->upload 303 $_->upload
305 for grep $_, @textures; 304 for values %TEXTURES;
306}; 305};
307 306
3081; 3071;
309 308
310=back 309=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines