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.110 by root, Mon May 28 21:33:28 2007 UTC vs.
Revision 1.111 by elmex, Thu Jun 7 14:45:22 2007 UTC

938=cut 938=cut
939 939
940sub load_tilecache() { 940sub load_tilecache() {
941 require Gtk2; 941 require Gtk2;
942 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
943 if (-e "$LIB/crossfire.0") { # Crossfire1 version 978 } elsif (-e "$LIB/crossfire.0") { # Crossfire1 version
944 cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", \&use_tilecache, 979 cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", \&use_tilecache,
945 sub { 980 sub {
946 my $tile = read_pak "$LIB/crossfire.0"; 981 my $tile = read_pak "$LIB/crossfire.0";
947 982
948 my %cache; 983 my %cache;
968 construct_tilecache_pb $idx, \%cache; 1003 construct_tilecache_pb $idx, \%cache;
969 1004
970 \%cache 1005 \%cache
971 }; 1006 };
972 1007
973 } else { # Crossfire+ version
974 cache_file "$LIB/facedata", "$VARDIR/tilecache.pst", \&use_tilecache,
975 sub {
976 my %cache;
977 my $facedata = Storable::retrieve "$LIB/facedata";
978
979 $facedata->{version} == 2
980 or die "$LIB/facedata: version mismatch, cannot proceed.";
981
982 my $faces = $facedata->{faceinfo};
983 my $idx = 0;
984
985 for (sort keys %$faces) {
986 my ($face, $info) = ($_, $faces->{$_});
987
988 my $pb = new Gtk2::Gdk::PixbufLoader;
989 $pb->write ($info->{data32});
990 $pb->close;
991 my $pb = $pb->get_pixbuf;
992
993 my $tile = $cache{$face} = {
994 pb => $pb,
995 idx => $idx,
996 w => int $pb->get_width / TILESIZE,
997 h => int $pb->get_height / TILESIZE,
998 };
999
1000 $idx += $tile->{w} * $tile->{h};
1001 }
1002
1003 construct_tilecache_pb $idx, \%cache;
1004
1005 \%cache
1006 };
1007 } 1008 }
1008} 1009}
1009 1010
1010=head1 AUTHOR 1011=head1 AUTHOR
1011 1012

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines