Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for the case compress was passed an empty string. Converted

make-tileset.pl to emit FSON rather than FML. Added the compress and base64 modules to the unix makefile.
  • Loading branch information...
commit d424ee1520b30cb7e74671a0820b9b861fe807ac 1 parent 62c8f31
@sweetkristas sweetkristas authored
Showing with 113 additions and 105 deletions.
  1. +2 −0  Makefile.common
  2. +106 −104 make-tileset.pl
  3. +5 −1 src/compress.cpp
View
2  Makefile.common
@@ -10,6 +10,7 @@ objects = \
animation_preview_widget.o \
asserts.o \
background.o \
+ base64.o \
blur.o \
border_widget.o \
button.o \
@@ -18,6 +19,7 @@ objects = \
checksum.o \
code_editor_dialog.o \
code_editor_widget.o \
+ compress.o \
current_generator.o \
decimal.o \
editor_dialogs.o \
View
210 make-tileset.pl
@@ -15,7 +15,7 @@
my $command_line = "$0 " . (join ' ', @ARGV);
print "# Generated on $date using:\n# $command_line\n";
-print "[tiles]\n";
+print "{\n";
my $tilename = shift @ARGV;
my $base = shift @ARGV;
@@ -44,9 +44,11 @@
$tilename = " $tilename";
}
+print "tile_pattern: [\n";
+
printf qq~
+{
#horizontal tile
-[tile_pattern]
image=$image
tiles=%s
%s
@@ -54,12 +56,12 @@
.* , ,.* ,
$friend,$tilename,$friend,
.* , ,.* "
-[/tile_pattern]
+},
~, &coord($base, 3, 1), $solid ;
printf qq~
#horizontal tile with one tile below but not on either side
-[tile_pattern]
+{
image=$image
tiles=%s
%s
@@ -67,12 +69,12 @@
.* , ,.* ,
$friend,$tilename,$friend,
,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 0, 5), $solid;
printf qq~
#horizontal tile with one tile above but not on either side
-[tile_pattern]
+{
image=$image
tiles=%s
%s
@@ -80,12 +82,12 @@
,$friend, ,
$friend,$tilename,$friend,
.* , , .*"
-[/tile_pattern]
+},
~, &coord($base, 2, 5), $solid;
printf qq~
#overhang
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -94,12 +96,12 @@
.* , ,.* ,
,$tilename,$friend,
.* , ,.* "
-[/tile_pattern]
+},
~, &coord($base, 3, 0), $solid;
printf qq~
#overhang - reversed
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -108,12 +110,12 @@
.* , ,.* ,
$friend,$tilename, ,
.* , ,.* "
-[/tile_pattern]
+},
~, &coord($base, 3, 2), $solid;
printf qq~
#sloped
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -122,12 +124,12 @@
, ,$friend?,
,$tilename,$friend,
$friend,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 0, $noslopes ? 0 : 7), (($solid eq 'solid=yes' and not $noslopes) ? 'solid=diagonal' : $solid);
printf qq~
#sloped - tile immediately beneath
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -138,13 +140,13 @@
.*,$friend,$tilename,$friend,.*,
.*,$friend,$friend,$friend,.*,
.*,.*,.*,.*,.*"
-[/tile_pattern]
+},
~, &coord($base, $noslopes ? 5 : 1, $noslopes ? 1 : 7), $solid;
printf qq~
#sloped - reversed
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -153,12 +155,12 @@
$friend?, , ,
$friend,$tilename, ,
$friend,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 0, $noslopes ? 2 : 8), (($solid eq 'solid=yes' and not $noslopes) ? 'solid=reverse_diagonal' : $solid);
printf qq~
#sloped - reversed - tile immediately beneath
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -169,13 +171,13 @@
.*,$friend,$tilename,$friend,.*,
.*,$friend,$friend,$friend,.*,
.*,.*,.*,.*,.*"
-[/tile_pattern]
+},
~, &coord($base, $noslopes ? 5 : 1, $noslopes ? 0 : 8), $solid;
printf qq~
#single tile by itself
-[tile_pattern]
+{
image=$image
tiles=%s
%s
@@ -183,12 +185,12 @@
.*, , .*,
,$tilename, ,
.*, , .*"
-[/tile_pattern]
+},
~, &coord($base, 3, 3), $solid;
printf qq~
#top of thin platform
-[tile_pattern]
+{
image=$image
tiles=%s
%s
@@ -196,12 +198,12 @@
.*, , .*,
,$tilename, ,
.*,$friend, .*"
-[/tile_pattern]
+},
~, &coord($base, 0, 3), $solid;
printf qq~
#part of thin platform
-[tile_pattern]
+{
image=$image
tiles=%s
$solid
@@ -209,12 +211,12 @@
.*,$friend, .*,
,$tilename, ,
.*,$friend, .*"
-[/tile_pattern]
+},
~, &coord($base, 1, 3);
printf qq~
#bottom of thin platform
-[tile_pattern]
+{
image=$image
tiles=%s
$solid
@@ -222,12 +224,12 @@
.*,$friend, .*,
,$tilename, ,
.*, , .*"
-[/tile_pattern]
+},
~, &coord($base, 2, 3);
printf qq~
#cliff edge
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -236,12 +238,12 @@
.*, ,$friend?,
,$tilename,$friend ,
$friend?,$friend,$friend "
-[/tile_pattern]
+},
~, &coord($base, 0, 0), $solid;
printf qq~
#cliff edge - reverse
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -250,12 +252,12 @@
$friend?, ,.* ,
$friend,$tilename, ,
$friend,$friend,$friend?"
-[/tile_pattern]
+},
~, &coord($base, 0, 2), $solid;
printf qq~
#cliff edge -- version with a corner underneath/opposite
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -264,12 +266,12 @@
.*, ,$friend?,
,$tilename,$friend ,
$friend?,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 0, 6), $solid;
printf qq~
#cliff edge (reversed) -- version with a corner underneath/opposite
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -278,12 +280,12 @@
$friend?, ,.*,
$friend,$tilename, ,
,$friend,$friend?"
-[/tile_pattern]
+},
~, &coord($base, 0, 4), $solid;
printf qq~
#middle of a cross
-[tile_pattern]
+{
image=$image
tiles=%s
$solid
@@ -291,12 +293,12 @@
,$friend, ,
$friend,$tilename,$friend ,
,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 1, 5);
printf qq~
#corner at two angles
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -305,12 +307,12 @@
$friend,$friend, ,
$friend,$tilename,$friend,
,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 3, 5);
printf qq~
#corner at two angles (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -319,12 +321,12 @@
,$friend,$friend,
$friend,$tilename,$friend,
$friend,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 3, 4);
printf qq~
#corners on the top
-[tile_pattern]
+{
image=$image
tiles=%s
$solid
@@ -332,12 +334,12 @@
,$friend, ,
$friend,$tilename,$friend,
$friend,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 5, 8);
printf qq~
#corners on the bottom
-[tile_pattern]
+{
image=$image
tiles=%s
$solid
@@ -345,12 +347,12 @@
$friend,$tilename,$friend,
$friend,$tilename,$friend,
,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 4, 8);
printf qq~
#corners both on the same side
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -359,12 +361,12 @@
,$friend,$friend,
$friend,$tilename,$friend,
,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 4, 7);
printf qq~
#corners both on the same side (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -373,12 +375,12 @@
$friend,$friend, ,
$friend,$tilename,$friend,
$friend,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 4, 6);
printf qq~
#inner top corner piece
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -387,12 +389,12 @@
$friend,$friend,$friend,
$friend,$tilename,$friend,
,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 4, 1);
printf qq~
#inner top corner piece (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -401,12 +403,12 @@
$friend,$friend,$friend,
$friend,$tilename,$friend,
$friend,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 4, 0);
printf qq~
#inner bottom corner piece
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -415,12 +417,12 @@
,$friend,$friend,
$friend,$tilename,$friend,
$friend,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 5, 1);
printf qq~
#inner bottom corner piece (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -429,12 +431,12 @@
$friend,$friend, ,
$friend,$tilename,$friend,
$friend,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 5, 0);
printf qq~
#corner at three sides
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -443,12 +445,12 @@
,$friend,$friend,
$friend,$tilename,$friend,
,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 4, 3);
printf qq~
#corner at three sides (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -457,12 +459,12 @@
$friend,$friend, ,
$friend,$tilename,$friend,
,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 4, 2);
printf qq~
#corner at three sides
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -471,12 +473,12 @@
,$friend, ,
$friend,$tilename,$friend,
,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 5, 3);
printf qq~
#corner at three sides (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -485,12 +487,12 @@
,$friend, ,
$friend,$tilename,$friend,
$friend,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 5, 2);
printf qq~
#roof at a corner
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -499,12 +501,12 @@
,$friend,$friend,
$friend,$tilename,$friend,
.*, , .*"
-[/tile_pattern]
+},
~, &coord($base, 5, 7);
printf qq~
#roof at a corner (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -513,12 +515,12 @@
$friend,$friend, ,
$friend,$tilename,$friend,
.*, , .*"
-[/tile_pattern]
+},
~, &coord($base, 5, 6);
printf qq~
#roof
-[tile_pattern]
+{
image=$image
tiles=%s
$solid
@@ -526,12 +528,12 @@
.* ,$friend, .*,
$friend,$tilename,$friend,
.*, , .*"
-[/tile_pattern]
+},
~, &coord($base, 2, 1);
printf qq~
#bottom corner
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -540,12 +542,12 @@
$friend?,$friend,$friend,
,$tilename,$friend,
.* , , .*"
-[/tile_pattern]
+},
~, &coord($base, 2, 0);
printf qq~
#bottom corner (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -554,12 +556,12 @@
$friend,$friend,$friend?,
$friend,$tilename, ,
.* , , .*"
-[/tile_pattern]
+},
~, &coord($base, 2, 2);
printf qq~
#bottom corner with corner on opposite side
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -568,12 +570,12 @@
$friend?,$friend, ,
,$tilename,$friend,
.* , , .*"
-[/tile_pattern]
+},
~, &coord($base, 2, 6);
printf qq~
#bottom corner with corner on opposite side (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -582,12 +584,12 @@
,$friend,$friend?,
$friend,$tilename, ,
.* , , .*"
-[/tile_pattern]
+},
~, &coord($base, 2, 4);
printf qq~
#solid
-[tile_pattern]
+{
image=$image
tiles=%s
$solid
@@ -595,13 +597,13 @@
$friend?,$friend,$friend?,
$friend,$tilename,$friend,
$friend?,$friend,$friend?"
-[/tile_pattern]
+},
~, &coord($base, 1, 1);
printf qq~
#cliff face coming up from a one-tile thick cliff and expanding out
#in one direction
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -610,13 +612,13 @@
$friend,$friend,.* ,
$friend,$tilename, ,
,$friend,.* "
-[/tile_pattern]
+},
~, &coord($base, 4, 5);
printf qq~
#cliff face coming up from a one-tile thick cliff and expanding out
#in one direction (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -625,13 +627,13 @@
.* ,$friend,$friend,
,$tilename,$friend,
.* ,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 4, 4);
printf qq~
#cliff face coming down from a one-tile thick cliff and expanding out
#in one direction
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -640,13 +642,13 @@
,$friend,.* ,
$friend,$tilename, ,
$friend,$friend,.* "
-[/tile_pattern]
+},
~, &coord($base, 5, 5);
printf qq~
#cliff face coming down from a one-tile thick cliff and expanding out
#in one direction (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -655,13 +657,13 @@
.* ,$friend, ,
,$tilename,$friend,
.* ,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 5, 4);
printf qq~
#cliff face coming both up and down from a one-tile thick cliff and expanding
#out into a ledge in one direction
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -670,13 +672,13 @@
,$friend,.* ,
$friend,$tilename, ,
,$friend,.* "
-[/tile_pattern]
+},
~, &coord($base, 1, 4);
printf qq~
#cliff face coming both up and down from a one-tile thick cliff and expanding
#out into a ledge in one direction (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -685,12 +687,12 @@
.* ,$friend, ,
,$tilename,$friend,
.* ,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 1, 6);
printf qq~
#cliff face
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -699,12 +701,12 @@
.* ,$friend,.* ,
,$tilename,$friend,
.* ,$friend,.* "
-[/tile_pattern]
+},
~, &coord($base, 1, 0);
printf qq~
#cliff face (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -713,12 +715,12 @@
.* ,$friend,.* ,
$friend,$tilename, ,
.* ,$friend,.* "
-[/tile_pattern]
+},
~, &coord($base, 1, 2);
printf qq~
#ground - with a corner on one side beneath
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -727,12 +729,12 @@
.* , ,.* ,
$friend,$tilename,$friend,
,$friend,$friend"
-[/tile_pattern]
+},
~, &coord($base, 3, 7), $solid;
printf qq~
#ground - with a corner on one side beneath (reversed)
-[tile_pattern]
+{
image=$image
reverse=no
tiles=%s
@@ -741,12 +743,12 @@
.* , ,.* ,
$friend,$tilename,$friend,
$friend,$friend, "
-[/tile_pattern]
+},
~, &coord($base, 3, 6), $solid;
printf qq~
#ground
-[tile_pattern]
+{
image=$image
tiles=%s
%s
@@ -754,7 +756,7 @@
$friend?, ,$friend?,
$friend ,$tilename ,$friend ,
$friend?,$friend?,$friend?"
-[/tile_pattern]
+},
~, &coord($base, 0, 1), $solid;
sub base_unencode($) {
@@ -778,4 +780,4 @@ ($$$)
return &base_encode($row) . &base_encode($col);
}
-print "[/tiles]\n";
+print "]\n}\n";
View
6 src/compress.cpp
@@ -27,7 +27,11 @@ std::vector<char> compress(const std::vector<char>& data, int compression_level)
do {
strm.avail_in = (in.size() - pos_in) > CHUNK ? CHUNK : in.size() - pos_in;
flush = (strm.avail_in + pos_in) == in.size() ? Z_FINISH : Z_NO_FLUSH;
- strm.next_in = reinterpret_cast<Bytef*>(&in[pos_in]);
+ if(in.size()) {
+ strm.next_in = reinterpret_cast<Bytef*>(&in[pos_in]);
+ } else {
+ strm.next_in = 0;
+ }
do {
out.resize(pos_out - out.size() + CHUNK);
strm.avail_out = CHUNK;
Please sign in to comment.
Something went wrong with that request. Please try again.