コード例 #1
0
ファイル: Converter.cpp プロジェクト: Astroua/CARTAvis
Converter* Converter::getConverter( const QString& oldUnits,
        const QString& newUnits) {
    Converter* converter = NULL;
    UnitType sourceUnitType = getUnitType( oldUnits );
    UnitType destUnitType = getUnitType( newUnits );
    if ( sourceUnitType == FREQUENCY_UNIT ) {
        if ( destUnitType == WAVELENGTH_UNIT || newUnits.isEmpty() ) {
            converter = new ConverterFrequencyWavelength( oldUnits, newUnits);
        } else if ( destUnitType == VELOCITY_UNIT ) {
            converter = new ConverterFrequencyVelocity( oldUnits, newUnits );
        } else if ( destUnitType == FREQUENCY_UNIT ) {
            converter = new ConverterFrequency( oldUnits, newUnits );
        }
    } else if ( sourceUnitType == VELOCITY_UNIT ) {
        if ( destUnitType == WAVELENGTH_UNIT || newUnits.isEmpty()) {
            converter = new ConverterVelocityWavelength( oldUnits, newUnits);
        } else if ( destUnitType == VELOCITY_UNIT ) {
            converter = new ConverterVelocity( oldUnits, newUnits );
        } else if ( destUnitType == FREQUENCY_UNIT ) {
            converter = new ConverterVelocityFrequency( oldUnits, newUnits );
        }
    } else if ( sourceUnitType == WAVELENGTH_UNIT ) {
        if ( destUnitType == WAVELENGTH_UNIT ) {
            converter = new ConverterWavelength( oldUnits, newUnits );
        } else if ( destUnitType == VELOCITY_UNIT || newUnits.isEmpty() ) {
            converter = new ConverterWavelengthVelocity( oldUnits, newUnits );
        } else if ( destUnitType == FREQUENCY_UNIT ) {
            converter = new ConverterWavelengthFrequency( oldUnits, newUnits );
        }
    } else if ( sourceUnitType == CHANNEL_UNIT ) {
        converter = new ConverterChannel( oldUnits, newUnits );
    }
    return converter;
}
コード例 #2
0
void RequirementsExpert::visitOwnUnitBoundaryItem(OwnUnitBoundaryItem* item)
{
    // Recognize units which are building at the moment.
    if (item->provideUnit.isConnected()) {
        auto planitem = item->provideUnit.getConnectedPort()->getOwner();
        auto morph = dynamic_cast<MorphUnitPlanItem*>(planitem);
        if ((morph != NULL) && (morph->getUnitType() == item->getUnitType()) && morph->isActive())
            return;
        auto build = dynamic_cast<BuildPlanItem*>(planitem);
        if ((build != NULL) && (build->getUnitType() == item->getUnitType()) && build->isActive())
            return;
    }
    addProvider(item->getUnitType(), item);
}
コード例 #3
0
void OwnUnitBoundaryItem::visitCompleteUnitUpdateEvent(CompleteUnitUpdateEvent* event)
{
    if (getUnitType() != event->unitType)
        supply.updateUnitType(event->unitType);
    AbstractSpaceUnitBoundaryItem::visitCompleteUnitUpdateEvent(event);
    provideUnit.updateData(event->unitType, event->pos);
}
コード例 #4
0
ファイル: ossimFgdcXmlDoc.cpp プロジェクト: LucHermitte/ossim
ossimRefPtr<ossimProjection> ossimFgdcXmlDoc::getProjection()
{
   if ( (m_projection.valid() == false) && isOpen() )
   {
      ossimString projName;
      if ( getProjCsn(projName) )
      {
         if (!projName.empty())
         {
            m_projection = ossimEpsgProjectionFactory::instance()->createProjection(projName);
            
            if ( m_projection.valid() )
            {
               ossimDpt gsd;
               gsd.makeNan();
               ossim_float64 d;
               if ( getXRes(d) )
               {
                  gsd.x = std::fabs(d);
               }
               if ( getYRes(d) )
               {
                  gsd.y = std::fabs(d);
               }
               ossimMapProjection* mapProj = dynamic_cast<ossimMapProjection*>(m_projection.get());
               if (mapProj)
               {
                  ossimDrect rect;
                  getBoundingBox(rect);
                  if (mapProj->isGeographic())
                  {
                     ossimGpt tie(rect.ul().lat, rect.ul().lon);
                     mapProj->setUlTiePoints(tie);
                     mapProj->setDecimalDegreesPerPixel(gsd);
                  }
                  else
                  {
                     ossimDpt tie(rect.ul().x, rect.ul().y);
                     ossimUnitType unitType = getUnitType();
                     if ( unitType == OSSIM_US_SURVEY_FEET)
                     {
                        gsd = gsd * US_METERS_PER_FT;
                        tie = tie * US_METERS_PER_FT;
                     }
                     else if ( unitType == OSSIM_FEET )
                     {
                        gsd = gsd * MTRS_PER_FT;
                        tie = tie * MTRS_PER_FT;
                     }
                        
                     mapProj->setUlTiePoints(tie);
                     mapProj->setMetersPerPixel(gsd);
                  }
               }
            }
         }
      }
   }
   return m_projection;
}
コード例 #5
0
void ResourceBoundaryItem::visitResourceUpdateEvent(ResourceUpdateEvent* event)
{
    lastSeen = info->lastUpdateTime;

    if(getUnitType().isMineralField())
        minerals = event->resources;
    else
    {
        gas = event->resources;
    }
}
コード例 #6
0
ファイル: SquadFileReader.cpp プロジェクト: rarosu/FnulAI
void SquadFileReader::addUnit(string line)
{
	Tokens token = split(line, ":");

	//Replace all _ with whitespaces, or they wont match
	replace(token.key);
	
	UnitType type = getUnitType(token.key);
	if (type.getID() != UnitTypes::Unknown.getID())
	{
		int no = toInt(token.value);
		cSquad->addSetup(type, toInt(token.value));
		return;
	}

	//No UnitType match found
	Broodwar->printf("Error: No matching UnitType found for %s", token.key.c_str());
}
コード例 #7
0
ファイル: unit-menu.cpp プロジェクト: AakashDabas/inkscape
bool UnitMenu::isRadial() const
{
    return getUnitType() == UNIT_TYPE_RADIAL;
}
コード例 #8
0
ファイル: unit-menu.cpp プロジェクト: AakashDabas/inkscape
bool UnitMenu::isAbsolute() const
{
    return getUnitType() != UNIT_TYPE_DIMENSIONLESS;
}
コード例 #9
0
ファイル: SquadFileReader.cpp プロジェクト: rarosu/FnulAI
vector<Squad*> SquadFileReader::readSquadList()
{
	string filename = getFilename("squads");
	
	//Read buildorder file
	ifstream inFile;

	stringstream ss;
	ss << getScriptPath();
	ss << "squads\\";
	ss << filename;
	string filePath = ss.str();

	inFile.open(filePath.c_str());

	if (!inFile)
	{
		Broodwar->printf("Unable to open file %s", filePath.c_str());
	}
	else
	{
		string line;
		char buffer[256];

		while (!inFile.eof())
		{
			inFile.getline(buffer, 100);
			if (buffer[0] != ';')
			{
				stringstream ss;
				ss << buffer;
				line = ss.str();
				
				Tokens token = split(line, "=");
				
				if (token.key == "Type")
				{
					type = token.value;
				}
				if (token.key == "Name")
				{
					name = token.value;
				}
				if (token.key == "MorphsTo")
				{
					morphsTo = getUnitType(token.value);
					//Broodwar->printf("FRU %s", morphsTo.getName().c_str());
				}
				if (token.key == "Priority")
				{
					priority = toInt(token.value);
					activePriority = priority;
				}
				if (token.key == "ActivePriority")
				{
					activePriority = toInt(token.value);
				}
				if (token.key == "OffenseType")
				{
					offType = token.value;
				}
				if (line == "<setup>")
				{
					createSquad();
				}
				if (token.key == "Unit")
				{
					addUnit(token.value);
				}
			}
		}
		inFile.close();
	}

	Broodwar->printf("Squad file %s loaded. %d squads added.", filePath.c_str(), (int)squads.size());
	
	return squads;
}
コード例 #10
0
void OwnUnitBoundaryItem::visitSimpleUnitUpdateEvent(SimpleUnitUpdateEvent* event)
{
    provideUnit.updateData(getUnitType(), event->pos);
    health = event->health;
}
コード例 #11
0
ファイル: ossimFgdcXmlDoc.cpp プロジェクト: LucHermitte/ossim
ossimRefPtr<ossimProjection> ossimFgdcXmlDoc::getGridCoordSysProjection()
{
   static const char M[] = "ossimFgdcXmlDoc::getGridCoordSysProjection";
   if ( traceDebug() )
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
   }

   if ( m_projection.valid() == false )
   {
      ossimString s;
      if ( getGridCoordinateSystem(s) )
      {
         ossimString gridsysn = s.downcase();
         if ( getHorizontalDatum(s) )
         {
            ossimString horizdn = s.downcase();
            const ossimDatum* datum = createOssimDatum(s); // throws exception
            
            if ( gridsysn == "universal transverse mercator" )
            {
               // Get the zone:
               if ( getUtmZone(s) )
               {
                  ossim_int32 zone = s.toInt32();

                  //---
                  // Note: Contruct with an origin with our datum.
                  // "proj->setDatum" does not change the origin's datum.
                  // This ensures theossimEpsgProjectionDatabase::findProjectionCode
                  // sets the psc code correctly down the line.
                  //---
                  ossimRefPtr<ossimUtmProjection> utmProj =
                     new ossimUtmProjection( *(datum->ellipsoid()), ossimGpt(0.0,0.0,0.0,datum) );
                  utmProj->setDatum(datum);
                  utmProj->setZone(zone);
                  
                  // Hemisphere( North false easting = 0.0, South = 10000000):
                  bool tmpResult = getUtmFalseNorthing(s);
                  if ( tmpResult && ( s != "0.0" ) )
                  {
                     utmProj->setHemisphere('S');
                  }
                  else
                  {
                     utmProj->setHemisphere('N');
                  }
                  utmProj->setPcsCode(0);

                  ossim_float64 xRes = 0.0;
                  ossim_float64 yRes = 0.0;
                  if (getXRes(xRes) && getYRes(yRes))
                  {
                     ossimDrect rect;
                     getBoundingBox(rect);

                     ossimDpt gsd(std::fabs(xRes), std::fabs(yRes));
                     ossimUnitType unitType = getUnitType();
                   
                     if (m_boundInDegree)
                     {
                        ossimGpt tieg(rect.ul().lat, rect.ul().lon);
                        utmProj->setUlTiePoints(tieg);
                     }
                     else
                     {
                        ossimDpt tie(rect.ul().x, rect.ul().y);
                        if ( unitType == OSSIM_US_SURVEY_FEET)
                        {
                           tie = tie * US_METERS_PER_FT;
                        }
                        else if ( unitType == OSSIM_FEET )
                        {
                           tie = tie * MTRS_PER_FT;
                        }
                        utmProj->setUlTiePoints(tie);
                     }

                     if ( unitType == OSSIM_US_SURVEY_FEET)
                     {
                        gsd = gsd * US_METERS_PER_FT;
                     }
                     else if ( unitType == OSSIM_FEET )
                     {
                        gsd = gsd * MTRS_PER_FT;
                     }
                     utmProj->setMetersPerPixel(gsd);
                  }
                  m_projection = utmProj.get(); // Capture projection.
               }
               else
               {
                  std::string errMsg = M;
                  errMsg += " ERROR: Could not determine utm zone!";
                  throw ossimException(errMsg);
               }
            }
         }
      }
   }
   
   if ( traceDebug() )
   {
      if ( m_projection.valid() )
      {
         m_projection->print(ossimNotify(ossimNotifyLevel_DEBUG));
      }
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " exiting...\n";
   }
   return m_projection;
}
コード例 #12
0
ファイル: SUnit.cpp プロジェクト: protective/anno3112
void SUnit::proces(uint32_t delta, Processor* processor){
	postProces(delta);
	
	if(_lastCombat < 1000000)
		_lastCombat++;
	
	if(this->_updateCounter)
		this->_updateCounter--;
	for(SSlotNodeI it = this->slots.begin(); it != this->slots.end(); it++){
		if (it->second->getSS())
			it->second->getSS()->proces(processor);
	}
	if(_order){
		if(_targetUpdateCounter % 5 == 0){
			_order->proces(OrdreEvent::Tick5,this);
		}
		if(_targetUpdateCounter % 10 == 0){
			_order->proces(OrdreEvent::Tick10,this);
		}
		if(_targetUpdateCounter % 25 == 0){
			_order->proces(OrdreEvent::Tick25,this);
		}
	}
	_targetUpdateCounter++;
	this->addRecoil(getUnitType()->getRecoilRecharge());
	if (_targetUpdateCounter % 5 == 0){
		this->updateTargetsPrio(_processor);
		this->addEnergy(_recharge/5);
	}
	if (_targetUpdateCounter % 25 == 0){
		if(_id == 2)
			setProgram(_processor->getPrograms()["test"]);
		updateTargetList(_processor);
		this->updateAutoMove();
		sendPosUpdate(SubscriptionLevel::lowFreq);

		
		this->_bonuslist.clear();
		for(SSlotNodeI it = this->slots.begin(); it != this->slots.end(); it++){
			if (it->second->getSS()){
				if (it->second->getSS()->isBonus()){
					it->second->getSS()->isBonus()->procesBonus(this);
				}
			}

		}
		this->_recharge = getUnitType()->getRecharge() * 1000;
		this->_maxEnergy = getUnitType()->getEnergy() * 1000;
		this->_maxdeflector = getUnitType()->getDeflector()*1000;
		//this->_deflector = stype.getDeflector()*1000;
		for (int i = 0; i< 6; i++){
			this->_maxshield[i] = getUnitType()->getShield(i) * getUnitType()->getShieldStr() * 10;
		}
		this->_maxarmor = getUnitType()->getArmor()*1000;
		this->_maxhull = getUnitType()->getHull()*1000;

		this->_scanRange = getUnitType()->getScanRange() * 100;
		this->_scanPRange = getUnitType()->getScanPRange() * 100;
		_topSpeed = getUnitType()->getTopSpeed() * 100;
		_agility = getUnitType()->getAgility();
		for (map<BonusTypes::Enum, int32_t>::iterator it = this->_bonuslist.begin(); it != this->_bonuslist.end();it++){
			switch(it->first){
				case BonusTypes::Armor:{this->_maxarmor+= it->second;break;}
				case BonusTypes::Deflector:{this->_maxdeflector+= it->second;break;}
				case BonusTypes::Hull:{this->_maxhull+= it->second;break;}
				case BonusTypes::ShieldStr:{
					for(uint32_t i = 0; i < 6 ; i++){
						this->_maxshield[i] += (this->getUnitType()->getShield(i) * it->second)/100;
					}
					break;
				}
				case BonusTypes::ERecharge:{this->_recharge+= it->second;break;}
				case BonusTypes::Energy:{this->_maxEnergy+= it->second;break;}
				case BonusTypes::ScanRange:{this->_scanRange+= (it->second/10);break;}
				case BonusTypes::ScanPRange:{this->_scanPRange+= (it->second/10);break;}
				case BonusTypes::SpeedThruster:{this->_topSpeed+= (it->second/(getUnitType()->getMass()/10));break;}
				case BonusTypes::ManuvereThruster:{this->_agility+= (it->second/(getUnitType()->getMass()*10));break;}			
			}
		}
		for(SSlotNodeI it = this->slots.begin(); it != this->slots.end(); it++){
			if (it->second->getSS())
				it->second->getSS()->reset();
		}
		//cerr<<"this->_topSpeed"<<this->_topSpeed<<endl;
	}
	if (_targetUpdateCounter == 100)
		_targetUpdateCounter = 0;
}