I've improved level format
See these dark gray squares? These are empty chunks. There maybe a lot of them because levels may not be in form of a rectangle.
When I didn't use chunks, I've had to save large empty areas because all tiles were stored in one big 2d array. So it looked like this in a file (-1 is an empty tile id):
1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,...
1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,...
1,1,4,1,5,1,1,1,-1,-1,-1,-1,-1,-1,...
1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,...
1,1,1,5,1,1,1,1,-1,-1,-1,-1,-1,-1,...
1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,...
1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,...
Lots of space wasted, right? Not anymore! Now I store levels like this (posX and posY indicate index of top-left tile in chunk):
...
chunk posX=-8 posY=-13
42,42,42,42,42,42,42,42,
30,30,30,30,30,30,30,30,
9,9,9,9,9,9,9,9,
13,13,13,13,13,13,13,13,
13,13,13,13,13,13,13,13,
52,52,52,52,52,52,52,52,
1,1,1,1,1,11,1,1,
31,1,11,2,1,1,23,1,
chunk posX=-32 posY=-5
1,1,1,1,1,13,13,13,
1,1,1,1,1,13,13,13,
1,1,1,1,1,13,13,13,
1,1,1,1,1,13,13,13,
1,1,1,1,1,13,13,13,
1,1,1,1,1,13,13,13,
1,1,1,1,1,13,13,13,
1,1,1,1,1,13,13,13,
...
Chunks are still stored in one 2d array (it's easier to work with them that way), but empty chunks are very lightweight (all they have is empty sf::VertexArray and std::vector<std::vector<int>>) so it's not a problem.