I did a search in this section for compression and didn't find anything really useful for those of you who would like to compress a map file here is some code that may help you out.
Code:
ifstream asd;
int counter = -1, data= 0, olddata,sets=0;
asd.open("game.dat");
data = mymap[0][0];
olddata = data;
for(h = 0;h < 50;h++)
{
for(w = 0;w < 100;w++)
{
counter++;
data = mymap[w][h];
if(data != olddata)
{
asd<<counter<<" "<<olddata<<endl;
counter=0;
}
olddata = data;
}
}
asd<<"999999";
asd.close();
here is a simple walkthrough of how this works.
1) Im assuming you have your map loaded into the array mine is 100x50 squares and have incuded fstream.h
2) we set the counter of repetitions to -1 because this code offsets it easy fix actually but i was just tring to get it to work at the time.
3) we loop for a while counting how many times we see the same number in a row. then we save the count and what tile it was to the file and start on the new one.
4) we keep doing that till we are done.
Ive obtained a 40% encryption on my map which is suitable atm. if you use alot of different tiles in your maps you may not want to use this because if the number of different tiles > 50% of your map size you will be lucky to break even. But for maps with water and somewhat open areas this compression can save alot of file space. In very extreme cases you can have nearly 99.9% compression to -100% compression (tile changes every time)
Hope this helps someone. Also note 999999 is just my way of saying "end" change to your liking