… | |
… | |
58 | outdoor temp pressure humid windspeed winddir sky nosmooth |
58 | outdoor temp pressure humid windspeed winddir sky nosmooth |
59 | tile_path_1 tile_path_2 tile_path_3 tile_path_4 |
59 | tile_path_1 tile_path_2 tile_path_3 tile_path_4 |
60 | )); |
60 | )); |
61 | |
61 | |
62 | our @FIELD_ORDER = (qw( |
62 | our @FIELD_ORDER = (qw( |
|
|
63 | inherit |
|
|
64 | |
63 | elevation |
65 | elevation |
64 | |
66 | |
65 | name name_pl custom_name attach title race |
67 | name name_pl custom_name attach title race |
66 | slaying skill msg lore other_arch face |
68 | slaying skill msg lore other_arch |
67 | #todo-events |
|
|
68 | animation is_animated |
69 | face animation is_animated |
|
|
70 | magicmap smoothlevel smoothface |
69 | str dex con wis pow cha int |
71 | str dex con wis pow cha int |
70 | hp maxhp sp maxsp grace maxgrace |
72 | hp maxhp sp maxsp grace maxgrace |
71 | exp perm_exp expmul |
73 | exp perm_exp expmul |
72 | food dam luck wc ac x y speed speed_left move_state attack_movement |
74 | food dam luck wc ac x y speed speed_left move_state attack_movement |
73 | nrof level direction type subtype attacktype |
75 | nrof level direction type subtype attacktype |
… | |
… | |
883 | }, sub { |
885 | }, sub { |
884 | read_arch "$LIB/archetypes" |
886 | read_arch "$LIB/archetypes" |
885 | }; |
887 | }; |
886 | } |
888 | } |
887 | |
889 | |
|
|
890 | sub construct_tilecache_pb { |
|
|
891 | my ($idx, $cache) = @_; |
|
|
892 | |
|
|
893 | my $pb = new Gtk2::Gdk::Pixbuf "rgb", 1, 8, 64 * TILESIZE, TILESIZE * int +($idx + 63) / 64; |
|
|
894 | |
|
|
895 | while (my ($name, $tile) = each %$cache) { |
|
|
896 | my $tpb = delete $tile->{pb}; |
|
|
897 | my $ofs = $tile->{idx}; |
|
|
898 | |
|
|
899 | for my $x (0 .. $tile->{w} - 1) { |
|
|
900 | for my $y (0 .. $tile->{h} - 1) { |
|
|
901 | my $idx = $ofs + $x + $y * $tile->{w}; |
|
|
902 | $tpb->copy_area ($x * TILESIZE, $y * TILESIZE, TILESIZE, TILESIZE, |
|
|
903 | $pb, ($idx % 64) * TILESIZE, TILESIZE * int $idx / 64); |
|
|
904 | } |
|
|
905 | } |
|
|
906 | } |
|
|
907 | |
|
|
908 | $pb->save ("$VARDIR/tilecache.png", "png", compression => 1); |
|
|
909 | |
|
|
910 | $cache |
|
|
911 | } |
|
|
912 | |
|
|
913 | sub use_tilecache { |
|
|
914 | my ($face) = @_; |
|
|
915 | $TILE = new_from_file Gtk2::Gdk::Pixbuf "$VARDIR/tilecache.png" |
|
|
916 | or die "$VARDIR/tilecache.png: $!"; |
|
|
917 | *FACE = $_[0]; |
|
|
918 | } |
|
|
919 | |
888 | =item load_tilecache |
920 | =item load_tilecache |
889 | |
921 | |
890 | (Re-)Load %TILE and %FACE. |
922 | (Re-)Load %TILE and %FACE. |
891 | |
923 | |
892 | =cut |
924 | =cut |
893 | |
925 | |
894 | sub load_tilecache() { |
926 | sub load_tilecache() { |
895 | require Gtk2; |
927 | require Gtk2; |
896 | |
928 | |
|
|
929 | if (-e "$LIB/crossfire.0") { # Crossfire1 version |
897 | cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", sub { |
930 | cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", \&use_tilecache, |
898 | $TILE = new_from_file Gtk2::Gdk::Pixbuf "$VARDIR/tilecache.png" |
931 | sub { |
899 | or die "$VARDIR/tilecache.png: $!"; |
|
|
900 | *FACE = $_[0]; |
|
|
901 | }, sub { |
|
|
902 | my $tile = read_pak "$LIB/crossfire.0"; |
932 | my $tile = read_pak "$LIB/crossfire.0"; |
903 | |
933 | |
904 | my %cache; |
934 | my %cache; |
905 | |
935 | |
906 | my $idx = 0; |
936 | my $idx = 0; |
907 | |
937 | |
908 | for my $name (sort keys %$tile) { |
938 | for my $name (sort keys %$tile) { |
909 | my $pb = new Gtk2::Gdk::PixbufLoader; |
939 | my $pb = new Gtk2::Gdk::PixbufLoader; |
910 | $pb->write ($tile->{$name}); |
940 | $pb->write ($tile->{$name}); |
911 | $pb->close; |
941 | $pb->close; |
912 | my $pb = $pb->get_pixbuf; |
942 | my $pb = $pb->get_pixbuf; |
913 | |
943 | |
914 | my $tile = $cache{$name} = { |
944 | my $tile = $cache{$name} = { |
915 | pb => $pb, |
945 | pb => $pb, |
916 | idx => $idx, |
946 | idx => $idx, |
917 | w => int $pb->get_width / TILESIZE, |
947 | w => int $pb->get_width / TILESIZE, |
918 | h => int $pb->get_height / TILESIZE, |
948 | h => int $pb->get_height / TILESIZE, |
|
|
949 | }; |
|
|
950 | |
|
|
951 | $idx += $tile->{w} * $tile->{h}; |
|
|
952 | } |
|
|
953 | |
|
|
954 | construct_tilecache_pb $idx, \%cache; |
|
|
955 | |
|
|
956 | \%cache |
919 | }; |
957 | }; |
|
|
958 | |
|
|
959 | } else { # Crossfire+ version |
|
|
960 | cache_file "$LIB/facedata", "$VARDIR/tilecache.pst", \&use_tilecache, |
|
|
961 | sub { |
|
|
962 | my %cache; |
|
|
963 | my $facedata = Storable::retrieve "$LIB/facedata"; |
|
|
964 | |
|
|
965 | $facedata->{version} == 2 |
|
|
966 | or die "$LIB/facedata: version mismatch, cannot proceed."; |
|
|
967 | |
|
|
968 | my $faces = $facedata->{faceinfo}; |
|
|
969 | my $idx = 0; |
|
|
970 | |
|
|
971 | for (sort keys %$faces) { |
|
|
972 | my ($face, $info) = ($_, $faces->{$_}); |
|
|
973 | |
|
|
974 | my $pb = new Gtk2::Gdk::PixbufLoader; |
|
|
975 | $pb->write ($info->{data32}); |
|
|
976 | $pb->close; |
|
|
977 | my $pb = $pb->get_pixbuf; |
|
|
978 | |
|
|
979 | my $tile = $cache{$face} = { |
|
|
980 | pb => $pb, |
|
|
981 | idx => $idx, |
|
|
982 | w => int $pb->get_width / TILESIZE, |
|
|
983 | h => int $pb->get_height / TILESIZE, |
920 | |
984 | }; |
921 | |
985 | |
922 | $idx += $tile->{w} * $tile->{h}; |
986 | $idx += $tile->{w} * $tile->{h}; |
923 | } |
|
|
924 | |
|
|
925 | my $pb = new Gtk2::Gdk::Pixbuf "rgb", 1, 8, 64 * TILESIZE, TILESIZE * int +($idx + 63) / 64; |
|
|
926 | |
|
|
927 | while (my ($name, $tile) = each %cache) { |
|
|
928 | my $tpb = delete $tile->{pb}; |
|
|
929 | my $ofs = $tile->{idx}; |
|
|
930 | |
|
|
931 | for my $x (0 .. $tile->{w} - 1) { |
|
|
932 | for my $y (0 .. $tile->{h} - 1) { |
|
|
933 | my $idx = $ofs + $x + $y * $tile->{w}; |
|
|
934 | $tpb->copy_area ($x * TILESIZE, $y * TILESIZE, TILESIZE, TILESIZE, |
|
|
935 | $pb, ($idx % 64) * TILESIZE, TILESIZE * int $idx / 64); |
|
|
936 | } |
987 | } |
|
|
988 | |
|
|
989 | construct_tilecache_pb $idx, \%cache; |
|
|
990 | |
|
|
991 | \%cache |
937 | } |
992 | }; |
938 | } |
|
|
939 | |
|
|
940 | $pb->save ("$VARDIR/tilecache.png", "png", compression => 1); |
|
|
941 | |
|
|
942 | \%cache |
|
|
943 | }; |
993 | } |
944 | } |
994 | } |
945 | |
995 | |
946 | =head1 AUTHOR |
996 | =head1 AUTHOR |
947 | |
997 | |
948 | Marc Lehmann <schmorp@schmorp.de> |
998 | Marc Lehmann <schmorp@schmorp.de> |