Show whole topic Oct 05, 2008 12:27 pm
Artlav Offline
Approved Member
Registered since: Jul 16, 2008
Location: Moscow


Subject: Re: resource stripper help
There seems to be many problems.
First, why the offset is 12768 and not 12763?
EDIT: Right, version 1.56 vs 1.04. It is 12768 in 1.04 and 12763 in 1.56, so that is all right.

Why unsigned char bmpdata[BMP_DIM / 2][BMP_DIM]; ?
You make a bitmap that is not a square, probably messing the things downcode.
Like, writebmp16(filename, BMP_DIM, BMP_DIM, (unsigned char *)&bmpdata);
Does not sound right to me.

DownloadSource code (Text):
  1.  infile.get(in);
  2.  infile.ignore(); // ignore the next character (this was probably originally stored as an int)
You ignore player visibility bitmask. Good, but comment makes it senseless.
You read bytes of resource distribution.

The resources block format is thus, in case you don't know it :
DownloadSource code (Text):
  1. 2 bytes per cell, left to right scanlines.
  2.  
  3. Byte 1 is resource type:
  4. if((b1>0x20)&&(b1<0x31))  fuel, b1-0x20 of it (0 thru 16)
  5. if((b1>0x40)&&(b1<0x51))  gold
  6. if((b1>0x80)&&(b1<0x91))  raw materials
  7.  
  8. Byte 2 is the player visibility bitmask.
  9. bit 2 - Gray player surveyed this cell
  10. bit 3 - Blue
  11. bit 4 - Green
  12. bit 5 - Red

So, your code below
DownloadSource code (Text):
  1. for(int i = 0; i < 112 && infile.tellg() <= 37854; i++){
  2.  for(int j = 0; j < 112 && infile.tellg() <= 37854; j++){
  3.   infile.get(in);
  4.   infile.ignore(); // ignore the next character (this was probably originally stored as an int)
  5.   //outfile << typetxt((unsigned char) in);
  6.   if(i % 2){   // if i is odd
  7.    bmpdata[i / 2][j] |= type((unsigned char)in); // set the low bits
  8.   }else{
  9.    bmpdata[i / 2][j] |= type((unsigned char)in) << 4; // set the high bits
  10.   }
  11.  }
  12.  //outfile << endl;
  13. }
Makes somewhat doubtful sense.

You can use my save game reader as a reference:
http://www.rumaxclub.ru/etc/maxse_081005.zip
It takes a save file as first parameter, and outputs bitmaps and information.
No source code, unless you ask for it.
Artyom Litvinovich
This post has been edited 1 times. Last edit on Oct 05, 2008 12:38 pm by Artlav.