示例#1
0
文件: mask.c 项目: tinyserver/siege
SGbool SG_EXPORT sgMaskCheckCollision(SGMask* m1, SGint x1, SGint y1, SGMask* m2, SGint x2, SGint y2)
{
	x1 -= m1->xoffset;
	y1 -= m1->yoffset;
	x2 -= m2->xoffset;
	y2 -= m2->yoffset;

	if(x2 > x1)
	{
		x2 -= x1;
		x1 = 0;
	}
	else
	{
		x1 -= x2;
		x2 = 0;
	}
	if(y2 > y1)
	{
		y2 -= y1;
		y1 = 0;
	}
	else
	{
		y1 -= y2;
		y2 = 0;
	}

	ptrdiff_t i, j;	
	for(i = 0; i < SG_MAX(m1->width, m2->width); i++)
		if((0 <= i - x1) && (i - x1 < m1->width)
		&& (0 <= i - x2) && (i - x2 < m2->width))
			for(j = 0; j < SG_MAX(m1->height, m2->height); j++)
				if((0 <= j - y1) && (j - y1 < m1->height)
				&& (0 <= j - y2) && (j - y2 < m2->height))
					if((!m1->precise || m1->field[i - x1][j - y1])
					&& (!m2->precise || m2->field[i - x2][j - y2]))
						return SG_TRUE;
	return SG_FALSE;
}
示例#2
0
static void my_dump_id(SG_context * pCtx,
					   const char* psz_hid,
					   SG_uint32 nrDigits,
					   SG_uint32 indent,
					   SG_string * pStringOutput)
{
	char buf[4000];

	// we can abbreviate the full IDs.

	nrDigits = SG_MIN(nrDigits, SG_HID_MAX_BUFFER_LENGTH);
	nrDigits = SG_MAX(nrDigits, 4);

	// create:
	//     Dagnode[addr]: <child_id> <gen> [<parent_id>...]

	SG_ERR_CHECK_RETURN(  SG_sprintf(pCtx,buf,SG_NrElements(buf),"%*c ",indent,' ')  );
	SG_ERR_CHECK_RETURN(  SG_string__append__sz(pCtx,pStringOutput,buf)  );
	SG_ERR_CHECK_RETURN(  SG_string__append__buf_len(pCtx,pStringOutput,(SG_byte *)(psz_hid),nrDigits)  );
	SG_ERR_CHECK_RETURN(  SG_string__append__sz(pCtx,pStringOutput,"\n")  );
}
示例#3
0
 */

size_t  sg_maxnum_stacks, sg_maxnum_stack, sg_maxnum_link, sg_maxnum_links;
size_t  sg_num_stacks, sg_num_stack, sg_num_links, sg_num_link;


void SG_ZeroAllocStats(void)
{
  sg_maxnum_stacks = sg_maxnum_stack = sg_maxnum_link = sg_maxnum_links =
  sg_num_stacks = sg_num_stack = sg_num_link = sg_num_links = 0;
}

void SG_MaxAllocStats(void)
{
  IF_STATISTICS(
    sg_maxnum_stacks = SG_MAX(sg_num_stacks, sg_maxnum_stacks);
    sg_maxnum_stack  = SG_MAX(sg_num_stack,  sg_maxnum_stack);
    sg_maxnum_links  = SG_MAX(sg_num_links,  sg_maxnum_links);
    sg_maxnum_link   = SG_MAX(sg_num_link,   sg_maxnum_link);
  );
}

void SG_PrintCurAllocStats(void)
{
  size_t total = 0, this;

  IF_STATISTICS(
    fprintf(SG_log(), "Current memory items used:\n\t"
            "datatype      number    sizeof()   subtotal\n");

    this = sg_num_stacks * sizeof(stacks); total += this;