Esempio n. 1
0
int FindCoords( Coords *coord ) {
    int tx, ty;

    if ( coord->x >= 0 ) {
        SetMap( coord );
        return( true );
    }
    else
    {
        for ( ty = 0; ty < out.ch; ty++ )
        {
            for ( tx = 0; tx < out.cw; tx++ )
            {
                coord->x = ( tx * xcharsize );
                coord->y = ( ty * ycharsize );

                if ( CheckCoords( coord ) && !TryPlace( coord ) ) {
                    SetMap( coord );
                    return( true );
                }
            }
        }
    }
    coord->x = -1;
    coord->y = -1;

    return( false );
}
Esempio n. 2
0
CPoint CStarmap::NearestPort(const std::vector<CSystem>& systems, const CPoint& start, const CString& owned_by)
{
	AssertBotE(IsOnMap(start.x, start.y));
	if(CheckCoords(start.x, start.y, owned_by, systems))
		return start;

	for(int radius = 1; radius < max(STARMAP_SECTORS_HCOUNT, STARMAP_SECTORS_VCOUNT); ++radius)
	{
		const int from_x = start.x - radius;
		const int to_x = start.x + radius;
		const int from_y = start.y - radius;
		const int to_y = start.y + radius;
		int x = from_x;
		int y = from_y;
		for(; x < to_x; ++x)
		{
			if(CheckCoords(x, y, owned_by, systems))
				return CPoint(x, y);
		}
		for(; y < to_y; ++y)
		{
			if(CheckCoords(x, y, owned_by, systems))
				return CPoint(x, y);
		}
		for(; x > from_x; --x)
		{
			if(CheckCoords(x, y, owned_by, systems))
				return CPoint(x, y);
		}
		for(; y > from_y; --y)
		{
			if(CheckCoords(x, y, owned_by, systems))
				return CPoint(x, y);;
		}
	}

	return CPoint(0, 0);
}
Esempio n. 3
0
int		GetFileDimensions()
{
    int			i;
    int			width, height;
    char		name[128];

    for (i = 0; i < filenum; i++)
    {
        in[i].index = i;

        strcpy(name, sourcedir);
        strcat(name, in[i].name);
        printf("Getting file dimensions, file : %s        \r", in[i].name);
        if(FileExists(name))
        {
            LoadAnyImage(name, NULL, NULL, &width, &height);
            in[i].depth = 32;
            in[i].rw = width;
            in[i].w = width;					 	// makes it width in
            in[i].h = height;
            in[i].cw = (in[i].w + (xcharsize - 1)) / xcharsize;
            in[i].ch = (in[i].h + (ycharsize - 1)) / ycharsize;

            if (!CheckCoords(&in[i]) && (in[i].x >= 0))
            {
                printf("Error : texture %s out of bounds.\n", in[i].name);
                return(false);
            }
            valid++;
        }
        else
        {
            in[i].depth = 0;
            in[i].x = -1;
            in[i].y = -1;
            in[i].w = 0;
            in[i].h = 0;
        }
    }
    printf("\n\n");
    return(true);
}