Map format
#2
Hey, this is just my best guess, maybe it will help you out.
From reading the code it looks like there are actually 1284 squares of the same type, (255*5 + 9).

I've annotated the code below. Of particular import is the 'spurge' macro which is what created that patch of FF's.

Like I said this is my best evaluation from a brief (5 minute) read of this code block, so please don't flame me if what I say is completely off.

// a pointer to the previous square
sqr *t = NULL;

// a count of identical squares
int sc = 0;

// f is a file descriptor I'd guess
// prints FF followed by the number (up to 255) of squares identical to the last as necessary to represent the total of sequential identical squares
#define spurge while(sc) { f->putchar(255); if(sc>255) { f->putchar(255); sc -= 255; } else { f->putchar(sc); sc = 0; } }



loopk(cubicsize)
    {
        // initialize the square index
        sqr *s = &world[k];

        // returns true if the property f is the same for square s and t
        #define c(f) (s->f==t->f)

        // 4 types of blocks, to compress a bit:
        // 255 (2): same as previous block + count
        // 254 (3): same as previous, except light // deprecated
        // SOLID (5)
        // anything else (9)

        // if the square is solid
        if(SOLID(s))
        {
            // and t exists, and s and t share the same type, wtex and vdelta
            if(t && c(type) && c(wtex) && c(vdelta))
            {
                // add one to the count of identical squares
                sc++;
            }
            else
            {
                // otherwise, write however many identical squares there were
                spurge;

                // and print one of the new type
                f->putchar(s->type);
                f->putchar(s->wtex);
                f->putchar(s->vdelta);
            }
        }
        else
        {
            // same as above, but for non-solid squares
            if(t && c(type) && c(floor) && c(ceil) && c(ctex) && c(ftex) && c(utex) && c(wtex) && c(vdelta) && c(tag))
            {
                sc++;
            }
            else
            {
                spurge;
                f->putchar(s->type);
                f->putchar(s->floor);
                f->putchar(s->ceil);
                f->putchar(s->wtex);
                f->putchar(s->ftex);
                f->putchar(s->ctex);
                f->putchar(s->vdelta);
                f->putchar(s->utex);
                f->putchar(s->tag);
            }
        }
        // t points to the last square checked
        t = s;
    }
    // end loop
    spurge;
    delete f;
    conoutf("wrote map file %s", cgzname);
Thanks given by:


Messages In This Thread
Map format - by Ronald_Reagan - 21 Dec 11, 03:27AM
RE: Map format - by MasterKaen - 21 Dec 11, 04:02AM
RE: Map format - by Ronald_Reagan - 21 Dec 11, 04:13AM
RE: Map format - by MasterKaen - 21 Dec 11, 05:01AM
RE: Map format - by Ronald_Reagan - 21 Dec 11, 05:32AM
RE: Map format - by MasterKaen - 21 Dec 11, 05:34AM
RE: Map format - by Ronald_Reagan - 21 Dec 11, 05:35AM
RE: Map format - by MasterKaen - 21 Dec 11, 05:44AM
RE: Map format - by Ronald_Reagan - 21 Dec 11, 05:51AM
RE: Map format - by MasterKaen - 21 Dec 11, 05:55AM
RE: Map format - by Mael - 21 Dec 11, 03:42PM
RE: Map format - by Ronald_Reagan - 21 Dec 11, 09:35PM
RE: Map format - by V-Man - 22 Dec 11, 08:27AM
RE: Map format - by Ronald_Reagan - 22 Dec 11, 08:48AM