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.107 by root, Wed May 9 11:44:40 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
347 } else { 347 } else {
348 warn "object $ob->{_name} has unknown material ($ob->{material}) set.\n"; 348 warn "object $ob->{_name} has unknown material ($ob->{material}) set.\n";
349 } 349 }
350 } 350 }
351 351
352 # check whether attachment is the same as in the archetype
353 if (exists $ob->{attach}) {
354 my $arch = $ARCH{$ob->{_name}};
355 my $js = JSON::XS->new->utf8->canonical (1);
356
357 if (defined $arch->{attach}
358 && $js->encode ($js->decode ($ob->{attach})) eq $js->encode ($arch->{attach})) {
359 delete $ob->{attach}
360 }
361 }
362
352 # 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
353 $ob->{magicmap} ||= delete $ob->{color_fg} if exists $ob->{color_fg}; 364 $ob->{magicmap} ||= delete $ob->{color_fg} if exists $ob->{color_fg};
354 365
355 # nuke outdated or never supported fields 366 # nuke outdated or never supported fields
356 delete @$ob{qw( 367 delete @$ob{qw(
927=cut 938=cut
928 939
929sub load_tilecache() { 940sub load_tilecache() {
930 require Gtk2; 941 require Gtk2;
931 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
932 if (-e "$LIB/crossfire.0") { # Crossfire1 version 978 } elsif (-e "$LIB/crossfire.0") { # Crossfire1 version
933 cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", \&use_tilecache, 979 cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", \&use_tilecache,
934 sub { 980 sub {
935 my $tile = read_pak "$LIB/crossfire.0"; 981 my $tile = read_pak "$LIB/crossfire.0";
936 982
937 my %cache; 983 my %cache;
957 construct_tilecache_pb $idx, \%cache; 1003 construct_tilecache_pb $idx, \%cache;
958 1004
959 \%cache 1005 \%cache
960 }; 1006 };
961 1007
962 } else { # Crossfire+ version
963 cache_file "$LIB/facedata", "$VARDIR/tilecache.pst", \&use_tilecache,
964 sub {
965 my %cache;
966 my $facedata = Storable::retrieve "$LIB/facedata";
967
968 $facedata->{version} == 2
969 or die "$LIB/facedata: version mismatch, cannot proceed.";
970
971 my $faces = $facedata->{faceinfo};
972 my $idx = 0;
973
974 for (sort keys %$faces) {
975 my ($face, $info) = ($_, $faces->{$_});
976
977 my $pb = new Gtk2::Gdk::PixbufLoader;
978 $pb->write ($info->{data32});
979 $pb->close;
980 my $pb = $pb->get_pixbuf;
981
982 my $tile = $cache{$face} = {
983 pb => $pb,
984 idx => $idx,
985 w => int $pb->get_width / TILESIZE,
986 h => int $pb->get_height / TILESIZE,
987 };
988
989 $idx += $tile->{w} * $tile->{h};
990 }
991
992 construct_tilecache_pb $idx, \%cache;
993
994 \%cache
995 };
996 } 1008 }
997} 1009}
998 1010
999=head1 AUTHOR 1011=head1 AUTHOR
1000 1012

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines