Ejemplo n.º 1
0
bool Walk::calcPath(uint16 oldArea, uint16 newArea) {
	debug(9, "Walk::calcPath(%d, %d)", oldArea, newArea);
	_areaList[1] = _areaStrike[1] = oldArea;
	_areaListCount = _areaStrikeCount = 1;
	uint16 area = oldArea;
	while (_areaListCount > 0 && area != newArea) {
		area = findFreeArea(area);
		if (!area) {
			// wrong path, rolling back
			_areaList[_areaListCount] = 0;
			--_areaListCount;
			area = _areaList[_areaListCount];
		} else {
			++_areaListCount;
			assert(_areaListCount < MAX_WALK_DATA);
			_areaList[_areaListCount] = area;
			if (!isAreaStruck(area)) {
				++_areaStrikeCount;
				assert(_areaStrikeCount < MAX_WALK_DATA);
				_areaStrike[_areaStrikeCount] = area;
			}
		}
	}
	return _areaList[1] != 0;
}
Ejemplo n.º 2
0
void HTMLClueV::appendRightAligned( HTMLClueAligned *_clue )
// This method adds _clue to the right aligned list.
// Its X-position is calculated based on the right margin
// at the Y-position of _clue. If _clue does not fit,
// its Y-position will be increased until it fits.
{
    int y_pos;
    int start_y = 0;
    int lmargin;
    int rmargin;
    HTMLClueAligned *clue;
    
    clue = alignRightList;
    if (clue)
    {
        while ( clue->nextClue() )
        {
           clue = clue->nextClue();
        }
        y_pos = clue->getYPos() + clue->parent()->getYPos();
	if (y_pos > start_y)
	    start_y = y_pos;
    }
    
    y_pos = _clue->getYPos() + _clue->parent()->getYPos();
    if (y_pos > start_y)
        start_y = y_pos;

    // Start looking for space from the position of the last object in 
    // the left-aligned list on, or from the current position of the
    // object.
    findFreeArea(start_y - _clue->getAscent(), 
    		_clue->getWidth(), _clue->getHeight(), 0,
    		&y_pos, &lmargin, &rmargin);
	
    // Set position
    _clue->setPos(rmargin - _clue->getWidth(), 
    	          y_pos - _clue->parent()->getYPos() + _clue->getAscent());	

    // Insert clue in align list
    if ( !alignRightList )
    {
	alignRightList = _clue;
	_clue->setNextClue( 0 );
    }
    else
    {
	HTMLClueAligned *obj = alignRightList;
	while ( obj->nextClue() )
	{
	    if ( obj == _clue )
	    {
		//printf("%s:%d Clue already in alignRightList\n", __FILE__, __LINE__);
		return;
	    }
	    obj = obj->nextClue();
	}
	if ( obj == _clue )
	{
	    //printf("%s:%d Clue already in alignRightList\n", __FILE__, __LINE__);
	    return;
	}
	obj->setNextClue( _clue );
	_clue->setNextClue( 0 );
    }
}