21 Dec 11, 04:02AM
(This post was last modified: 21 Dec 11, 05:57AM by MasterKaen.)
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.
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.
[SELECT ALL] Code:
// 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);