Author Topic: Ordering Of The Tiles In An Outpost2 .map File  (Read 8123 times)

Offline dazjorz

  • Newbie
  • *
  • Posts: 18
Ordering Of The Tiles In An Outpost2 .map File
« Reply #25 on: June 20, 2009, 12:11:16 PM »
I'll try to get it done once again. However, I did notice the width of an image was, for example, 80 pixels, and its scanLineByteWidth was also 80, ie 1 byte per pixel for every scanline. Is the scanLineByteWidth actually incorrect for these images, ie should it actually be ceil(width/8), or is there a lot of useless data after the real useful bytes?

Edit: I can't figure out the answer to my own question, at least. Every time I get something *close* to what I want to see, but never really the real deal. This is currently, in unoptimized code, what I do:

Code: [Select]
bmpFile_->seek( 0x436 + images[ imageId ].dataPtr );
int numBits = 0;
char byte;

for( int y = 0; y < images[ imageId ].height; ++y )
{
  for( int x = 0; x < images[ imageId ].width; ++x )
  {
    if( numBits == 0 )
    {
      if( bmpFile_->read( &byte, 1 ) != 1 )
      {
        qWarning() << "Failed to read image data: " << bmpFile_->errorString();
        SDL_FreeSurface( surface );
        return 0;
      }
      numBits = 8;
    }

    bool shadowSet = byte & 0x80;
    byte <<= 1;
    numBits--;

    // if this pixel has shadow set...
    if( shadowSet )
    {
        [...]
    }
  }
}

Ie, I just completely ignore image scanline and just read the bytes I need. I have also tried reading the bytes for one scanline, and start with a fresh byte the next vertical line; and I've also tried just reading scanLineByteWidth bytes and using these, and assuming the rest of the bytes are useless. This is what I currently see. The shadows just seem to appear at the right places for the buildings, but in a weird pattern that just indicates I read too few or too many bytes. Whatever I try, the image constantly looks something like that... Any ideas?

Edit: We talked about it on IRC; I just won't support shadows atm, oh well. Next up: Try to clone some interface stuff, and add support for selecting units and showing data on them in the menu...
« Last Edit: June 22, 2009, 08:26:02 PM by dazjorz »

Offline dazjorz

  • Newbie
  • *
  • Posts: 18
Ordering Of The Tiles In An Outpost2 .map File
« Reply #26 on: July 22, 2009, 03:38:39 PM »
BTW, this project is on hold for a while, I've got a lot of other stuff to do. Until I'm done, everybody can simply check the code at http://svn.dazjorz.com/svn/o2c. Feel free to make changes and send in patches, I'll give you commit access or whatever you need, but I won't be working on it myself for a while. :)