Exemplo n.º 1
0
/* The function converts the given value depending on the requested
   unit and its source unit. */
double transline::convertProperty (const char * prop, double value, int type,
				   int srcunit) {
  int dstunit = translateUnit (getUnit (prop));
  if (type == UNIT_LENGTH)
    value *= conv_length[srcunit][dstunit];
  else if (type == UNIT_RES)
    value *= conv_res[srcunit][dstunit];
  else if (type == UNIT_ANG)
    value *= conv_ang[srcunit][dstunit];
  else if (type == UNIT_FREQ)
    value *= conv_freq[srcunit][dstunit];
  return value;
}
Exemplo n.º 2
0
void DebugDraw::DrawLine(const sf::Vector2f& p1, const sf::Vector2f& p2, float thick, const sf::Color& c)
{
    float distance = getDistance(p1, p2);
    sf::Vector2f dir = getUnit(p2 - p1);

    sf::RectangleShape line(sf::Vector2f(distance, thick));
    line.setOrigin(0, thick/2.f);
    line.setPosition(p1);
    line.setRotation(atan2(dir.y, dir.x) * (180/3.14159f));
    line.setFillColor(c);

    window->draw(line);
}
Exemplo n.º 3
0
/**
 * Fits drawing on page. Affects DXF variable $PINSBASE.
 */
bool RS_Graphic::fitToPage() {
    bool ret(true);
    double border = RS_Units::convert(25.0, RS2::Millimeter, getUnit());
    RS_Vector ps = getPaperSize();
    if(ps.x>border && ps.y>border) ps -= RS_Vector(border, border);
    RS_Vector s = getSize();
    /** avoid zero size, bug#3573158 */
    if(fabs(s.x)<RS_TOLERANCE) s.x=10.;
    if(fabs(s.y)<RS_TOLERANCE) s.y=10.;
    double fx = RS_MAXDOUBLE;
    double fy = RS_MAXDOUBLE;
    double fxy;
    //ps = RS_Units::convert(ps, getUnit(), RS2::Millimeter);

    // tin-pot 2011-12-30: TODO: can s.x < 0.0 (==> fx < 0.0) happen?
    if (fabs(s.x) > 1.0e-10) {
        fx = ps.x / s.x;
        ret=false;
    }
    if (fabs(s.y) > 1.0e-10) {
        fy = ps.y / s.y;
        ret=false;
    }

    fxy = std::min(fx, fy);
    if (fxy >= RS_MAXDOUBLE || fxy <= 1.0e-10) {
        setPaperSize(
                    RS_Units::convert(RS_Vector(210.,297.)
                                      , RS2::Millimeter
                                      , getUnit()
                                      )
                    );
        ret=fitToPage();
    }
    setPaperScale(fxy);
    centerToPage();
    return ret;
}
Exemplo n.º 4
0
Action GameState::makeAttack(int attId, int defId, int aMoveTgt) const
{
    const auto &attacker = getUnit(attId);
    const auto &defender = getUnit(defId);
    if (!attacker.isAlive() || !defender.isAlive()) return {};

    Action action;
    action.attacker = attId;
    action.defender = defId;
    action.aTgt = defender.aHex;

    bool attMoved = (aMoveTgt != attacker.aHex);

    if (!attMoved && isRangedAttackAllowed(attId, defId)) {
        action.type = ActionType::RANGED;
        return action;
    }
    if (!attMoved && isSpellAllowed(attId, defId)) {
        action.type = ActionType::EFFECT;
        action.damage = attacker.num * attacker.type->spell->damage;
        action.effect = Effect(*this, action, attacker.type->spell->effect);
        action.manaCost = attacker.type->spell->cost;
        return action;
    }

    bool isAdjacent = contains(grid_.aryNeighbors(aMoveTgt), defender.aHex);
    if (!isAdjacent || !isMeleeAttackAllowed(attId, defId)) {
        return {};
    }

    auto path = getPath(attacker, aMoveTgt);
    if (path.empty() || path.size() > attacker.getMaxPathSize()) {
        return {};
    }
    action.type = ActionType::ATTACK;
    action.path = path;
    return action;
}
Exemplo n.º 5
0
 IProperty *
 Property :: getFlagConstant(int32_t position)
 {
   IProperty *retval = 0;
   try
   {
     if (getType() != IProperty::PROPERTY_FLAGS)
       throw std::runtime_error("flag is not of type PROPERTY_FLAGS");
     
     // now, iterate through all options, counting all CONSTS that belong
     // to the same unit as this option
     const char* unit = getUnit();
     if (!unit || !*unit)
       throw std::runtime_error("flag doesn't have a unit setting, so can't tell what constants");
     
     // Create a fake class 
     AVClass fakeClass;
     fakeClass.class_name="XuggleFakeClass";
     fakeClass.item_name = fakeContextToName;
     fakeClass.option = mOptionStart;
     AVClass *fakeClassPtr = &fakeClass;
     
     const AVOption* last = 0;
     int32_t constNo = -1;
     do
     {
       last = av_opt_next(&fakeClassPtr, last);
       if (last &&
           last->unit &&
           last->type == AV_OPT_TYPE_CONST &&
           strcmp(unit, last->unit)==0)
       {
         // count in the same was as getNumFlagSettings,
         // and then return if the position is equal
         ++constNo;
         if (constNo == position)
         {
           retval = Property::make(av_opt_next(&fakeClassPtr, 0), last);
         }
       }
     } while(last);
     
   }
   catch (std::exception & e)
   {
     VS_LOG_DEBUG("Error: %s", e.what());
     VS_REF_RELEASE(retval);
   }
   return retval;
 }
Exemplo n.º 6
0
/**
 * Get the number of time units a certain action takes.
 * @param actionType
 * @param item
 * @return TUs
 */
int BattleUnit::getActionTUs(BattleActionType actionType, BattleItem *item) const
{
	if (item == 0)
	{
		return 0;
	}

	switch (actionType)
	{
		case BA_PRIME:
			return (int)floor(getUnit()->getTimeUnits() * 0.50);
		case BA_THROW:
			return (int)floor(getUnit()->getTimeUnits() * 0.25);
		case BA_AUTOSHOT:
			return (int)(getUnit()->getTimeUnits() * item->getRules()->getTUAuto() / 100);
		case BA_SNAPSHOT:
			return (int)(getUnit()->getTimeUnits() * item->getRules()->getTUSnap() / 100);
		case BA_AIMEDSHOT:
			return (int)(getUnit()->getTimeUnits() * item->getRules()->getTUAimed() / 100);
		default:
			return 0;
	}
}
Exemplo n.º 7
0
void getData(ifstream& input,vector<Bus>& vecBus,vector<ACline>& vecACLine,
				vector<TopoNode>& vecTopoNode,vector<Unit>& vecUnit,
				vector<Transformer>& vecTransformer,vector<Load>& vecLoad)
{//调用其他get函数,一次性读取
//有必要了解input的getline是怎么工作的。
//使用过一次,然后再次使用是有影响的
//所有在使用输入流时应该注意顺序,否则会导致无法跳出
	getBusData(input,vecBus);
	getAClineData(input,vecACLine);	
	getUnit(input,vecUnit);
	getTransData(input,vecTransformer);
	//load函数位置
	getLoadData(input,vecLoad);
	getTopoNode(input,vecTopoNode);	
}
Exemplo n.º 8
0
Arquivo: fight.cpp Projeto: q4a/attal
void Fight::socketFightMove()
{
	attalFightData dataFight;

	dataFight.cla = _socket->readChar();
	dataFight.num = _socket->readChar();
	dataFight.row = _socket->readInt();
	dataFight.col = _socket->readInt();
	
	dataFight.dataType = FIGHT_DATA_MOVE;
	
	dataFight.unit = getUnit( dataFight.num, (CLASS_FIGHTER)dataFight.cla) ;
	
	manageData( dataFight );
}
Exemplo n.º 9
0
std::vector<int> GameState::getAllEnemies(int id) const
{
    const auto &unit = getUnit(id);
    if (!unit.isAlive()) return {};

    std::vector<int> enemies;

    for (const auto &u : units_) {
        if (u.isAlive() && unit.isEnemy(u)) {
            enemies.push_back(u.entityId);
        }
    }

    return enemies;
}
Exemplo n.º 10
0
int GameState::assignDamage(int id, int damage)
{
    auto &unit = getUnit(id);
    assert(unit.isValid());

    int numKilled = unit.takeDamage(damage);
    if (!unit.isAlive()) {
        unitAtPos_[unit.aHex] = -1;
    }
    if (numKilled > 0) {
        drawTimer_ = ROUNDS_TO_DRAW;
    }

    return numKilled;
}
Exemplo n.º 11
0
void UnitMoveAction::activate()
{
	Action::activate();

	UnitInput i = UNIT_UNKNOWN;

	if ( m_input == "LEFT" )		i = UNIT_MOVE_LEFT;
	else if ( m_input == "RIGHT" )	i = UNIT_MOVE_RIGHT;
	else if ( m_input == "UP" )		i = UNIT_MOVE_UP;
	else if ( m_input == "DOWN" )	i = UNIT_MOVE_DOWN;
	else throw std::runtime_error( "Unknown UnitInput value" );

	getUnit()->setForcedMove( i );
	m_activateElapsedTime = 0;
}
	bool actualizeMembers(test_suite& suite, const std::deque<test_unit_id>& members) {
		const std::size_t suiteSize = suite.size();
		const std::size_t memSize = members.size();
		if (suiteSize != memSize) {
			//diff size
			DEPENDENCY_LOG_ERROR( "Members size[" << memSize << "] differs from sute size[" << suiteSize << "]" );
			return false;
		} else {
			//obtain all pointers
			std::vector<test_unit*> units(memSize);
			bool gotAllUnits = true;
			//std::deque<test_unit_id>::const_iterator iter = members.begin();
			//std::deque<test_unit_id>::const_iterator eiter = members.end();
			for(std::size_t i =0; i<memSize; i++) {
				DependencyId unitId = members[i];
				test_unit* unit = getUnit(unitId);
				if (unit!=NULL) {
					units[i] = unit;
				} else {
					DEPENDENCY_LOG_ERROR( "Could not get member[" << unitId << "]" );
					gotAllUnits = false;
				}
			}

			if (gotAllUnits==false) {
				DEPENDENCY_LOG_ERROR( "Could not get all members" );
				return false;
			} else {
				//remove old tests
				for(std::size_t i=0; i<suiteSize; i++) {
					suite.remove( members[i] );
				}
				const std::size_t newSuiteSize = suite.size();
				if (newSuiteSize>0) {
					DEPENDENCY_LOG_ERROR( "Could not clear the suite" );
					return false;
				} else {
					//add tests in correct order

					for(std::size_t i=0; i<memSize; i++) {
						test_unit* unit = units[i];
						suite.add(unit, unit->p_expected_failures, unit->p_timeout);
					}
				}
			}
			return true;
		}
	}
Exemplo n.º 13
0
void UnitMng::generateInputs()
{
	BWAPI::Unit *enemyUnit=0;
	BWAPI::Unit *tempUnit=getUnit();
	
	//Units position

	//mapWidth() is in TilePosition Units which is 32 pixels
	inputs[0]=((tempUnit->getPosition().x())/(BWAPI::Broodwar->mapWidth()*32.0));
	inputs[1]=(tempUnit->getPosition().y())/(BWAPI::Broodwar->mapHeight()*32.0);
	//Group leader position
	inputs[2]=(UnitGroup->getPosition().x())/(BWAPI::Broodwar->mapWidth()*32.0);
	inputs[3]=(UnitGroup->getPosition().y())/(BWAPI::Broodwar->mapHeight()*32.0);
	//How many hit points?
	inputs[4]=getHitPoints();
	// Is there an enemy within the unit's seek range?
	enemyUnit=enemyExists(tempUnit);
	inputs[5]=enemyUnit?1.0:0;
	// Find closest enemy
	enemyUnit=closestEnemy();
	inputs[6]=enemyUnit?(UnitGroup->getPosition().x())/(BWAPI::Broodwar->mapWidth()*32.0):1.0;
	inputs[7]=enemyUnit?(UnitGroup->getPosition().y())/(BWAPI::Broodwar->mapHeight()*32.0):1.0;
	inputs[8]=underAttack();
	//check surroundings
	//east
	inputs[9]=getBlocked(0,1);
	//north-east
	inputs[10]=getBlocked(1,1);
	//north
	inputs[11]=getBlocked(1,0);
	//north-west
	inputs[12]=getBlocked(1,-1);
	//west
	inputs[13]=getBlocked(0,-1);
	//south-west
	inputs[14]=getBlocked(-1,-1);
	//south
	inputs[15]=getBlocked(-1,0);
	//south-east
	inputs[16]=getBlocked(-1,1);
	//Get Group Command;
	inputs[17]=GroupCommand();
	//get last Command or not maybe useless
	inputs[18]=getLastCommand();	
	//bias
	inputs[19]=1.0;
	//return inputs;
}
Exemplo n.º 14
0
Action GameState::makeMove(int id, int aTgt) const
{
    const auto &unit = getUnit(id);
    if (!unit.isAlive()) return {};

    auto path = getPath(unit, aTgt);
    if (path.size() <= 1 || path.size() > unit.getMaxPathSize()) {
        return {};
    }

    Action action;
    action.type = ActionType::MOVE;
    action.attacker = id;
    action.path = path;
    return action;
}
Exemplo n.º 15
0
std::vector<int> GameState::getAdjEnemies(int id, int aIndex) const
{
    const auto &unit = getUnit(id);
    if (!unit.isAlive()) return {};

    std::vector<int> enemies;

    for (auto n : grid_.aryNeighbors(aIndex)) {
        const auto &adjUnit = getUnitAt(n);
        if (adjUnit.isAlive() && unit.isEnemy(adjUnit)) {
            enemies.push_back(adjUnit.entityId);
        }
    }

    return enemies;
}
Exemplo n.º 16
0
double UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr) const
{
    double old_factor = getUnit()->factor;
    if (old_unit_abbr != "no_unit") {
        old_factor = unit_table.getUnit(old_unit_abbr)->factor;
    }
    Unit const * new_unit = unit_table.getUnit(new_unit_abbr);

    // Catch the case of zero or negative unit factors (error!)
    if (old_factor < 0.0000001 ||
        new_unit->factor < 0.0000001) {
        // TODO:  Should we assert here?
        return 0.00;
    }

    return old_factor / new_unit->factor;
}
Exemplo n.º 17
0
void UnitInterface::unitOpcodeMessage(const NetMessage *net_message, size_t size)
{
    UnitOpcodeDecoder decoder;
    decoder.setMessage(net_message, size);

    UnitOpcode* opcode;
    while(decoder.decode(&opcode)) {
        UnitBase* unit = getUnit(opcode->getUnitID());

        if(!unit) {
            LOGGER.debug("Update for non-existant unit: %d",
                    opcode->getUnitID());
            continue;
        }
        
        unit->evalCommandOpcode(opcode);
    }
}
Exemplo n.º 18
0
void batchWindow::addImage(QString url, int batch, float size)
{
	m_urls.append(url);
	QTableWidgetItem *id = new QTableWidgetItem(QString::number(m_items+1));
	id->setIcon(QIcon(":/images/colors/black.png"));
	ui->tableWidget->setItem(m_items, 0, id);
	ui->tableWidget->setItem(m_items, 1, new QTableWidgetItem(QString::number(batch)));
	ui->tableWidget->setItem(m_items, 2, new QTableWidgetItem(url));
	QString unit = getUnit(&size);
	ui->tableWidget->setItem(m_items, 3, new QTableWidgetItem(size != 0 ? QLocale::system().toString(size, 'f', size < 10 ? 2 : 0)+" "+unit : ""));
	ui->tableWidget->setItem(m_items, 4, new QTableWidgetItem());
	ui->tableWidget->setItem(m_items, 5, new QTableWidgetItem("0 %"));
	/* QProgressBar *prog = new QProgressBar(this);
	prog->setTextVisible(false);
	m_progressBars.append(prog);
	ui->tableWidget->setCellWidget(m_items, 5, prog); */
	m_items++;
}
Exemplo n.º 19
0
void UnitInterface::unitKilled(const UnitBase* unit, const UnitID killer)
{
    UnitBase* unit2 = getUnit(killer);
    if ( ! unit2 )
    {
        LOGGER.warning(
                "Killer Unit in EndLifeCycle message doesn't exist anymore(u1: %u u2: %u)",
                unit->id, killer);
        return;
    }
    
    PlayerState* player1 = PlayerInterface::getPlayer(unit->player_id);
    PlayerState* player2 = PlayerInterface::getPlayer(unit2->player_id);

    int unittype1 = unit->unit_state.unit_type;
    const std::string& unitname1 = UnitProfileInterface::getUnitProfile(unittype1)->unitname;
    
    int unittype2 = unit2->unit_state.unit_type;
    const std::string& unitname2 = UnitProfileInterface::getUnitProfile(unittype2)->unitname;
    
    if(Console::server)
    {
        *Console::server << "'" << player1->getName() << "' killed a '"
            << unitname2 << "' from '" << player2->getName() 
            << "' with his '" << unitname1 << "'." << std::endl;
    }

    // killing team own units doesn't give score
    if (GameConfig::game_teammode && (player1->getTeamID() == player2->getTeamID()))
    {
        return;
    }
    
    // killing own units doesn't give score
    if( player1 != player2 ) 
    {
        PlayerInterface::setKill(player1, player2, (UnitType) unittype1);
        
        PlayerScoreUpdate score_update;
        score_update.set(player1->getID(), player2->getID(), (UnitType) unittype1);
        
        SERVER->broadcastMessage(&score_update, sizeof(PlayerScoreUpdate));
    }
}
Exemplo n.º 20
0
Arquivo: fight.cpp Projeto: q4a/attal
void Fight::socketFightModify()
{
	TRACE("socket modify");
	GenericFightUnit * unit;
	uchar cla = _socket->readChar();
	uchar num = _socket->readChar();
	uchar race = _socket->readChar();
	uchar level = _socket->readChar();
	int number = _socket->readInt();
	uchar move =_socket->readChar();
	int health =_socket->readInt();

	unit = getUnit ( num, (CLASS_FIGHTER)cla);

	unit->setCreature( race, level );
	unit->setNumber( number );
	unit->setMove( move );
	unit->setHealth( health );
}
	bool DependencySolver::normalizeDepenencies(DependencyId unitId, const DependencyIdSet& depSet) {
		bool ret = true;
		//framework::get(unit);
		test_unit* unit = getUnit(unitId);

		//DependencyId unitParentId = unit->parent_id_t;
		DependencyLevel unitLevel = levels.at(unitId);

		DependencyIdSet::iterator iter = depSet.begin();
		DependencyIdSet::iterator eiter = depSet.end();
		for(; iter!=eiter; iter++) {
			//LogInfo << *iter << ", ";
			//check_dep(levels, unitId, *iter);

			DependencyId currId = *iter;

			DependencyLevel currLevel = levels.at(currId);
			DependencyLevel levelDiff = unitLevel - currLevel;
			if (levelDiff>0) {
				//unit is deeper
				DependencyId unitAncestorId = getAncestorId(unitId, levelDiff);
				bool valid = checkAncestor(currLevel, unitAncestorId, currId);
				if (valid==false) {
					DEPENDENCY_LOG_ERROR( "Unit test [" << unit->p_name << "] depends on his sub-tree (not registered) #1" );
					ret = false;
				}
			} else {
				//current is deeper or on the same level
				DependencyId currAncestorId = getAncestorId(currId, -levelDiff);
				bool valid = checkAncestor(unitLevel, unitId, currAncestorId);
				if (valid==false) {
					if (levelDiff==0) {
						DEPENDENCY_LOG_ERROR( "Unit test [" << unit->p_name << "] depends on himself (not registered)" );
					} else {
						DEPENDENCY_LOG_ERROR( "Unit test [" << unit->p_name << "] depends on his sub-tree (not registered) #2" );
					}
					ret = false;
				}
			}
		}
		return ret;
	}
Exemplo n.º 22
0
MEventList::MEventList(IPackage&p)
{
        list.setAutoDelete(true);
        p.pos(0);
        QString n=p.name(),c;p>>c;
        //Unit Events
        if((n=="get"&&c=="unit")||
           (n=="set"&&(c=="create unit"||c=="modify unit"))){
                //unit manipulation events
                //load nums
                uint32 net;uint16 nou;
                p>>net>>nou;
                SUnit u;
                //load units
                for(;nou>0;nou--){
                        u.mask=0;
                        getUnit(u,p);
                        list.append(new MUnitEvent(net,u));
                }
        }else
Exemplo n.º 23
0
/**
 * Fits drawing on page. Affects DXF variable $PINSBASE.
 */
void RS_Graphic::fitToPage() {
	double border = RS_Units::convert(25.0, RS2::Millimeter, getUnit());
	RS_Vector ps = getPaperSize() - RS_Vector(border, border);
	RS_Vector s = getSize();
	double fx = RS_MAXDOUBLE;
	double fy = RS_MAXDOUBLE;
	//double factor = 1.0;

	//ps = RS_Units::convert(ps, getUnit(), RS2::Millimeter);

	if (fabs(s.x)>1.0e-6) {
		fx = ps.x / s.x;
	}
	if (fabs(s.y)>1.0e-6) {
		fy = ps.y / s.y;
	}

	setPaperScale(std::min(fx, fy));
	centerToPage();
}
Exemplo n.º 24
0
QVariant RMemoryStorage::getKnownVariable(RS::KnownVariable key) const {
    if (key==RS::INSUNITS) {
        return getUnit();
    }
    else if (key==RS::LTSCALE) {
        return getLinetypeScale();
    }
    // if DIMADEC is -1, DIMDEC is used:
    else if (key==RS::DIMADEC &&
             knownVariables.contains(RS::DIMDEC) &&
             knownVariables.value(RS::DIMDEC).toInt()==-1) {
        return getKnownVariable(RS::DIMDEC);
    }
    else if (key==RS::DWGCODEPAGE) {
        return "ANSI_1252";
    }
    else {
        return knownVariables.value(key);
    }
}
Exemplo n.º 25
0
QString Image::tooltip() const
{
	if (m_isGallery)
		return QStringLiteral("%1%2")
			.arg(m_id == 0 ? " " : tr("<b>ID:</b> %1<br/>").arg(m_id))
			.arg(m_name.isEmpty() ? " " : tr("<b>Name:</b> %1<br/>").arg(m_name));

	double size = m_fileSize;
	QString unit = getUnit(&size);

	return QStringLiteral("%1%2%3%4%5%6%7%8")
		.arg(m_tags.isEmpty() ? " " : tr("<b>Tags:</b> %1<br/><br/>").arg(stylishedTags(m_profile).join(" ")))
		.arg(m_id == 0 ? " " : tr("<b>ID:</b> %1<br/>").arg(m_id))
		.arg(m_rating.isEmpty() ? " " : tr("<b>Rating:</b> %1<br/>").arg(m_rating))
		.arg(m_hasScore ? tr("<b>Score:</b> %1<br/>").arg(m_score) : " ")
		.arg(m_author.isEmpty() ? " " : tr("<b>User:</b> %1<br/><br/>").arg(m_author))
		.arg(m_size.width() == 0 || m_size.height() == 0 ? " " : tr("<b>Size:</b> %1 x %2<br/>").arg(QString::number(m_size.width()), QString::number(m_size.height())))
		.arg(m_fileSize == 0 ? " " : tr("<b>Filesize:</b> %1 %2<br/>").arg(QString::number(size), unit))
		.arg(!m_createdAt.isValid() ? " " : tr("<b>Date:</b> %1").arg(m_createdAt.toString(tr("'the 'MM/dd/yyyy' at 'hh:mm"))));
}
Exemplo n.º 26
0
/**
 * Default constructor.
 */
RS_Graphic::RS_Graphic(RS_EntityContainer* parent)
        : RS_Document(parent),
        layerList(),
blockList(true),paperScaleFixed(false)
{

    RS_SETTINGS->beginGroup("/Defaults");
    setUnit(RS_Units::stringToUnit(RS_SETTINGS->readEntry("/Unit", "None")));
    RS_SETTINGS->endGroup();
    RS_SETTINGS->beginGroup("/Appearance");
    //$ISOMETRICGRID == $SNAPSTYLE
    addVariable("$SNAPSTYLE",static_cast<int>(RS_SETTINGS->readNumEntry("/IsometricGrid", 0)),70);
   crosshairType=static_cast<RS2::CrosshairType>(RS_SETTINGS->readNumEntry("/CrosshairType",0));
    RS_SETTINGS->endGroup();
    RS2::Unit unit = getUnit();

    if (unit==RS2::Inch) {
        addVariable("$DIMASZ", 0.1, 40);
        addVariable("$DIMEXE", 0.05, 40);
        addVariable("$DIMEXO", 0.025, 40);
        addVariable("$DIMGAP", 0.025, 40);
        addVariable("$DIMTXT", 0.1, 40);
    } else {
        addVariable("$DIMASZ",
                    RS_Units::convert(2.5, RS2::Millimeter, unit), 40);
        addVariable("$DIMEXE",
                    RS_Units::convert(1.25, RS2::Millimeter, unit), 40);
        addVariable("$DIMEXO",
                    RS_Units::convert(0.625, RS2::Millimeter, unit), 40);
        addVariable("$DIMGAP",
                    RS_Units::convert(0.625, RS2::Millimeter, unit), 40);
        addVariable("$DIMTXT",
                    RS_Units::convert(2.5, RS2::Millimeter, unit), 40);
    }
    addVariable("$DIMTIH", 0, 70);
    //initialize printer vars bug #3602444
    setPaperScale(getPaperScale());
    setPaperInsertionBase(getPaperInsertionBase());

    setModified(false);
}
Exemplo n.º 27
0
void GameState::nextTurn()
{
    if (roundNum_ == 0) {
        nextRound();
        return;
    }

    if (turnOrder_.empty()) return;

    ++curTurn_;
    int endOfRound = turnOrder_.size();
    while (curTurn_ < endOfRound && !getUnit(turnOrder_[curTurn_]).isAlive()) {
        ++curTurn_;
    }

    if (curTurn_ == endOfRound) {
        nextRound();
    }

    onStartTurn();
}
Exemplo n.º 28
0
bool Army::deleteUnit(int id)
{
	Unit* unit = getUnit(id);
	if (unit != nullptr)
	{
		std::cout << "Erase unit " << unit->getId() << std::endl;
		std::vector<Unit*>::iterator it;
		it = find(_units.begin(), _units.end(), unit);
		_units.erase(it);
		_unitFactory->removeInstances(unit->getName());
		_currentId = 1;
		for (unsigned int i = 0; i < _units.size(); i++)
		{
			_units[i]->setId(_currentId);
			_currentId++;
		}

		return true;
	}
	std::cout << "L'id n'existe pas" << std::endl;
	return false;
}
Exemplo n.º 29
0
 int32_t
 Property :: getNumFlagSettings()
 {
   int32_t retval = 0;
   try {
     if (getType() != IProperty::PROPERTY_FLAGS)
       throw std::runtime_error("flag is not of type PROPERTY_FLAGS");
     
     // now, iterate through all options, counting all CONSTS that belong
     // to the same unit as this option
     const char* unit = getUnit();
     if (!unit || !*unit)
       throw std::runtime_error("flag doesn't have a unit setting, so can't tell what constants");
     
     // Create a fake class 
     AVClass fakeClass;
     fakeClass.class_name="XuggleFakeClass";
     fakeClass.item_name = fakeContextToName;
     fakeClass.option = mOptionStart;
     AVClass *fakeClassPtr = &fakeClass;
     
     const AVOption* last = 0;
     do
     {
       last = av_opt_next(&fakeClassPtr, last);
       if (last &&
           last->unit &&
           last->type == AV_OPT_TYPE_CONST &&
           strcmp(unit, last->unit)==0)
         ++retval;
     } while(last);
   }
   catch (std::exception & e)
   {
     VS_LOG_DEBUG("Error: %s", e.what());
     retval = -1;
   }
   return retval;
 }
Exemplo n.º 30
0
CompilableUnit& Comp::compile(std::string filename)
{
    if ( boost::optional<CompilableUnit&> mu = getUnit(filename) )
        return *mu;

    CompilableUnit unit(filename);

    auto root = FileHelper::parse((filename + ".txt").c_str());

    unit.module_symbol = std::make_shared<ModuleSymbol>(unit.module_name, BuiltIns::global_scope.get());
    root -> scope = unit.module_symbol;
    root -> build_scope();

    DefineTypesVisitor define_types_visitor;
    root -> accept(define_types_visitor);

    ExpandTemplatesVisitor expand_visitor;
    root -> accept(expand_visitor);

    DefineVisitor define_visitor;
    root -> accept(define_visitor);

    unit.module_globals = unit.module_symbol -> allSymbols();

    CheckVisitor check_visitor;
    root -> accept(check_visitor);

    InlineCallVisitor inline_call_visitor;
    root -> accept(inline_call_visitor);

    GenSSAVisitor visitor(Comp::code);
    root -> accept(visitor);

    unit.root = std::move(root);

    Comp::units.push_back(std::move(unit));
    return Comp::units.back();
}