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

Comparing deliantra/Deliantra/Deliantra.pm (file contents):
Revision 1.108 by elmex, Wed May 23 20:21:28 2007 UTC vs.
Revision 1.111 by elmex, Thu Jun 7 14:45:22 2007 UTC

4 4
5=cut 5=cut
6 6
7package Crossfire; 7package Crossfire;
8 8
9our $VERSION = '0.98'; 9our $VERSION = '0.99';
10 10
11use strict; 11use strict;
12 12
13use base 'Exporter'; 13use base 'Exporter';
14 14
352 # check whether attachment is the same as in the archetype 352 # check whether attachment is the same as in the archetype
353 if (exists $ob->{attach}) { 353 if (exists $ob->{attach}) {
354 my $arch = $ARCH{$ob->{_name}}; 354 my $arch = $ARCH{$ob->{_name}};
355 my $js = JSON::XS->new->utf8->canonical (1); 355 my $js = JSON::XS->new->utf8->canonical (1);
356 356
357 if (defined $arch->{attach}
357 if ($js->encode ($js->decode ($ob->{attach})) eq $js->encode ($arch->{attach})) { 358 && $js->encode ($js->decode ($ob->{attach})) eq $js->encode ($arch->{attach})) {
358 delete $ob->{attach} 359 delete $ob->{attach}
359 } 360 }
360 } 361 }
361 362
362 # color_fg is used as default for magicmap if magicmap does not exist 363 # color_fg is used as default for magicmap if magicmap does not exist
937=cut 938=cut
938 939
939sub load_tilecache() { 940sub load_tilecache() {
940 require Gtk2; 941 require Gtk2;
941 942
943 if (-e "$LIB/facedata") { # Crossfire TRT faces
944 cache_file "$LIB/facedata", "$VARDIR/tilecache.pst", \&use_tilecache,
945 sub {
946 my %cache;
947 my $facedata = Storable::retrieve "$LIB/facedata";
948
949 $facedata->{version} == 2
950 or die "$LIB/facedata: version mismatch, cannot proceed.";
951
952 my $faces = $facedata->{faceinfo};
953 my $idx = 0;
954
955 for (sort keys %$faces) {
956 my ($face, $info) = ($_, $faces->{$_});
957
958 my $pb = new Gtk2::Gdk::PixbufLoader;
959 $pb->write ($info->{data32});
960 $pb->close;
961 my $pb = $pb->get_pixbuf;
962
963 my $tile = $cache{$face} = {
964 pb => $pb,
965 idx => $idx,
966 w => int $pb->get_width / TILESIZE,
967 h => int $pb->get_height / TILESIZE,
968 };
969
970 $idx += $tile->{w} * $tile->{h};
971 }
972
973 construct_tilecache_pb $idx, \%cache;
974
975 \%cache
976 };
977
942 if (-e "$LIB/crossfire.0") { # Crossfire1 version 978 } elsif (-e "$LIB/crossfire.0") { # Crossfire1 version
943 cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", \&use_tilecache, 979 cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", \&use_tilecache,
944 sub { 980 sub {
945 my $tile = read_pak "$LIB/crossfire.0"; 981 my $tile = read_pak "$LIB/crossfire.0";
946 982
947 my %cache; 983 my %cache;
967 construct_tilecache_pb $idx, \%cache; 1003 construct_tilecache_pb $idx, \%cache;
968 1004
969 \%cache 1005 \%cache
970 }; 1006 };
971 1007
972 } else { # Crossfire+ version
973 cache_file "$LIB/facedata", "$VARDIR/tilecache.pst", \&use_tilecache,
974 sub {
975 my %cache;
976 my $facedata = Storable::retrieve "$LIB/facedata";
977
978 $facedata->{version} == 2
979 or die "$LIB/facedata: version mismatch, cannot proceed.";
980
981 my $faces = $facedata->{faceinfo};
982 my $idx = 0;
983
984 for (sort keys %$faces) {
985 my ($face, $info) = ($_, $faces->{$_});
986
987 my $pb = new Gtk2::Gdk::PixbufLoader;
988 $pb->write ($info->{data32});
989 $pb->close;
990 my $pb = $pb->get_pixbuf;
991
992 my $tile = $cache{$face} = {
993 pb => $pb,
994 idx => $idx,
995 w => int $pb->get_width / TILESIZE,
996 h => int $pb->get_height / TILESIZE,
997 };
998
999 $idx += $tile->{w} * $tile->{h};
1000 }
1001
1002 construct_tilecache_pb $idx, \%cache;
1003
1004 \%cache
1005 };
1006 } 1008 }
1007} 1009}
1008 1010
1009=head1 AUTHOR 1011=head1 AUTHOR
1010 1012

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines