Exemplo n.º 1
0
static inline void infoTile(const QString & message, Tile * tile)
{
	if (tile == NULL) {
		DebugDialog::debug("infoTile: tile is NULL");
		return;
	}

	DebugDialog::debug(QString("tile:%1 lb:%2 bl:%3 tr:%4 rt%5")
		.arg((long) tile, 0, 16)
		.arg((long) tile->ti_lb, 0, 16)
		.arg((long) tile->ti_bl, 0, 16)
		.arg((long) tile->ti_tr, 0, 16)
		.arg((long) tile->ti_rt, 0, 16));

	DebugDialog::debug(QString("%1 tile:%2 l:%3 t:%4 w:%5 h:%6 type:%7 body:%8")
		.arg(message)
		.arg((long) tile, 0, 16)
		.arg(LEFT(tile))
		.arg(YMIN(tile))
		.arg(WIDTH(tile))
		.arg(HEIGHT(tile))
		.arg(TiGetType(tile))
		.arg((long) TiGetBody(tile), 0, 16)
	);
}
Exemplo n.º 2
0
static void miSubtractSpans (SpanGroup *spanGroup, Spans *sub)
{
    int		i, subCount, spansCount;
    int		ymin, ymax, xmin, xmax;
    Spans	*spans;
    DDXPointPtr	subPt, spansPt;
    int		*subWid, *spansWid;
    int		extra;

    ymin = YMIN(sub);
    ymax = YMAX(sub);
    spans = spanGroup->group;
    for (i = spanGroup->count; i; i--, spans++) {
	if (YMIN(spans) <= ymax && ymin <= YMAX(spans)) {
	    subCount = sub->count;
	    subPt = sub->points;
	    subWid = sub->widths;
	    spansCount = spans->count;
	    spansPt = spans->points;
	    spansWid = spans->widths;
	    extra = 0;
	    for (;;)
 	    {
		while (spansCount && spansPt->y < subPt->y)
		{
		    spansPt++;  spansWid++; spansCount--;
		}
		if (!spansCount)
		    break;
		while (subCount && subPt->y < spansPt->y)
		{
		    subPt++;	subWid++;   subCount--;
		}
		if (!subCount)
		    break;
		if (subPt->y == spansPt->y)
		{
		    xmin = subPt->x;
		    xmax = xmin + *subWid;
		    if (xmin >= spansPt->x + *spansWid || spansPt->x >= xmax)
		    {
			;
		    }
		    else if (xmin <= spansPt->x)
		    {
			if (xmax >= spansPt->x + *spansWid) 
			{
			    memmove (spansPt, spansPt + 1, sizeof *spansPt * (spansCount - 1));
			    memmove (spansWid, spansWid + 1, sizeof *spansWid * (spansCount - 1));
			    spansPt--;
			    spansWid--;
			    spans->count--;
			    extra++;
			}
			else 
			{
			    *spansWid = *spansWid - (xmax - spansPt->x);
			    spansPt->x = xmax;
			}
		    }
		    else
		    {
			if (xmax >= spansPt->x + *spansWid)
			{
			    *spansWid = xmin - spansPt->x;
			}
			else
			{
			    if (!extra) {
				DDXPointPtr newPt;
				int	    *newwid;

#define EXTRA 8
				newPt = (DDXPointPtr) realloc(spans->points, (spans->count + EXTRA) * sizeof (DDXPointRec));
				if (!newPt)
				    break;
				spansPt = newPt + (spansPt - spans->points);
				spans->points = newPt;
				newwid = (int *) realloc(spans->widths, (spans->count + EXTRA) * sizeof (int));
				if (!newwid)
				    break;
				spansWid = newwid + (spansWid - spans->widths);
				spans->widths = newwid;
				extra = EXTRA;
			    }
			    memmove (spansPt + 1, spansPt, sizeof *spansPt * (spansCount));
			    memmove (spansWid + 1, spansWid, sizeof *spansWid * (spansCount));
			    spans->count++;
			    extra--;
			    *spansWid = xmin - spansPt->x;
			    spansWid++;
			    spansPt++;
			    *spansWid = *spansWid - (xmax - spansPt->x);
			    spansPt->x = xmax;
			}
		    }
		}
		spansPt++;  spansWid++; spansCount--;
	    }
	}
    }
}