double
AudioContext::CurrentTime() const
{
  MediaStream* stream = Destination()->Stream();
  return stream->StreamTimeToSeconds(stream->GetCurrentTime() +
                                     Destination()->ExtraCurrentTime());
}
void MultiplesTangentes::draw()
{
    if(Dessinable())
    {
        ofPushStyle();
        ofEnableAlphaBlending();
        ofSetColor(255, 255, 255, Alpha() * 255);
        ofSetLineWidth(lineWidth());
        float distance(Tools::getDistance(*Origine(), *Destination()));
        float angle(Tools::getAngle(*Origine(), *Destination()));
        ofVec2f milieu(Origine()->getMiddle(*Destination()));
        tangente()->Origine(&milieu);
        tangente()->rayon(distance / 2.);
        tangente()->Dessinable(Dessinable());
        tangente()->Alpha(Alpha());
        tangente()->lineWidth(lineWidth());

        for(int i = 0; i < nombreDeTangentesMax(); i += _step)
        {
            tangente()->angle(angle * (1 + i / (float)nombreDeTangentesMax() * M_PI));
            tangente()->draw();
        }

        ofDisableAlphaBlending();
        ofPopStyle();
    }
}
MediaStream*
AudioContext::DestinationStream() const
{
  if (Destination()) {
    return Destination()->Stream();
  }
  return nullptr;
}
Exemple #4
0
void cMonster::InStateIdle(std::chrono::milliseconds a_Dt)
{
	if (m_IsFollowingPath)
	{
		return;  // Still getting there
	}

	m_IdleInterval += a_Dt;

	if (m_IdleInterval > std::chrono::seconds(1))
	{
		// At this interval the results are predictable
		int rem = m_World->GetTickRandomNumber(6) + 1;
		m_IdleInterval -= std::chrono::seconds(1);  // So nothing gets dropped when the server hangs for a few seconds

		Vector3d Dist;
		Dist.x = (double)m_World->GetTickRandomNumber(10) - 5;
		Dist.z = (double)m_World->GetTickRandomNumber(10) - 5;

		if ((Dist.SqrLength() > 2)  && (rem >= 3))
		{
			Vector3d Destination(GetPosX() + Dist.x, 0, GetPosZ() + Dist.z);
			Destination.y = FindFirstNonAirBlockPosition(Destination.x, Destination.z);
			MoveToPosition(Destination);
		}
	}
}
already_AddRefed<Promise>
AudioContext::Resume(ErrorResult& aRv)
{
  nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(GetParentObject());
  nsRefPtr<Promise> promise;
  promise = Promise::Create(parentObject, aRv);
  if (aRv.Failed()) {
    return nullptr;
  }

  if (mIsOffline) {
    promise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
    return promise.forget();
  }

  if (mAudioContextState == AudioContextState::Closed ||
      mCloseCalled) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
    return promise.forget();
  }

  if (mAudioContextState == AudioContextState::Running) {
    promise->MaybeResolve(JS::UndefinedHandleValue);
    return promise.forget();
  }

  Destination()->Resume();

  mPromiseGripArray.AppendElement(promise);
  Graph()->ApplyAudioContextOperation(DestinationStream()->AsAudioNodeStream(),
                                      AudioContextOperation::Resume, promise);

  return promise.forget();
}
Exemple #6
0
void BattleSpellCastParameters::aimToStack(const CStack * destination)
{
	if(nullptr == destination)
		logGlobal->error("BattleSpellCastParameters::aimToStack invalid stack.");
	else
		destinations.push_back(Destination(destination));
}
Exemple #7
0
void cMonster::InStateIdle(float a_Dt)
{
	if (m_bMovingToDestination)
	{
		return; // Still getting there
	}

	m_IdleInterval += a_Dt;

	if (m_IdleInterval > 1)
	{
		// At this interval the results are predictable
		int rem = m_World->GetTickRandomNumber(6) + 1;
		m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds

		Vector3d Dist;
		Dist.x = (double)m_World->GetTickRandomNumber(10) - 5;
		Dist.z = (double)m_World->GetTickRandomNumber(10) - 5;

		if ((Dist.SqrLength() > 2)  && (rem >= 3))
		{
			Vector3d Destination(GetPosX() + Dist.x, 0, GetPosZ() + Dist.z);

			int NextHeight = FindFirstNonAirBlockPosition(Destination.x, Destination.z);

			if (IsNextYPosReachable(NextHeight))
			{
				Destination.y = NextHeight;
				MoveToPosition(Destination);
			}
		}
	}
}
already_AddRefed<Promise>
AudioContext::Close(ErrorResult& aRv)
{
  nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(GetParentObject());
  RefPtr<Promise> promise;
  promise = Promise::Create(parentObject, aRv);
  if (aRv.Failed()) {
    return nullptr;
  }

  if (mIsOffline) {
    promise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
    return promise.forget();
  }

  if (mAudioContextState == AudioContextState::Closed) {
    promise->MaybeResolve(NS_ERROR_DOM_INVALID_STATE_ERR);
    return promise.forget();
  }

  if (Destination()) {
    Destination()->DestroyAudioChannelAgent();
  }

  mPromiseGripArray.AppendElement(promise);

  // This can be called when freeing a document, and the streams are dead at
  // this point, so we need extra null-checks.
  MediaStream* ds = DestinationStream();
  if (ds) {
    nsTArray<MediaStream*> streams;
    // If mSuspendCalled or mCloseCalled are true then we already suspended
    // all our streams, so don't suspend them again. But we still need to do
    // ApplyAudioContextOperation to ensure our new promise is resolved.
    if (!mSuspendCalled && !mCloseCalled) {
      streams = GetAllStreams();
    }
    Graph()->ApplyAudioContextOperation(ds->AsAudioNodeStream(), streams,
                                        AudioContextOperation::Close, promise);
  }
  mCloseCalled = true;

  return promise.forget();
}
void Perpendiculaire::draw()
{
    if(Dessinable())
    {
        ofPushStyle();
        ofEnableAlphaBlending();
        ofSetColor(255, 255, 255, Alpha() * 255);
        ofSetLineWidth(lineWidth());
        float angle(Tools::getAngle(*Origine(), *Destination()));
        ofVec2f AB(Destination()->x - Origine()->x, Destination()->y - Origine()->y);
        ofPushMatrix();
        ofTranslate(*Origine() + positionRelative * AB);
        ofRotateZ(angle);

        if(showSymbole)
        {
            float tailleSymbole(ofClamp(10 * lineWidth(), 15, 50));
            ofLine(0, tailleSymbole, tailleSymbole, tailleSymbole);
            ofLine(tailleSymbole, 0, tailleSymbole, tailleSymbole);
        }

        ofVec2f from(0, -ofGetHeight() * 2);
        ofVec2f to(0, ofGetHeight() * 2);

        if(typeTrace() == TRACE_POINTILLES)
        {
            SegmentDroite pointilles(ofxOscRouterBaseNode::getFirstOscNodeAlias() + "-segment", '@', &from, &to, TRACE_POINTILLES);
            pointilles.Alpha(Alpha());
            pointilles.Dessinable(Dessinable());
            pointilles.lineWidth(lineWidth());
            pointilles.offset(offset());
            pointilles.draw();
        }
        else
        {
            ofLine(from, to);
        }

        ofPopMatrix();
        ofDisableAlphaBlending();
        ofPopStyle();
    }
}
Exemple #10
0
Log::LogFile::LogFile(const string& filename) {
  #ifdef _WIN32
  _sopen_s(&file_descriptor, filename.c_str(), _O_APPEND | _O_RDWR | _O_CREAT,
      _SH_DENYNO, _S_IREAD | _S_IWRITE);
  #else
    file_descriptor = open(filename.c_str(), O_APPEND | O_RDWR | O_CREAT,
      S_IRUSR | S_IWUSR);
  #endif
  file_log = Destination(new rlog::StdioNode(file_descriptor, DEFAULT_FLAGS));
}
Exemple #11
0
already_AddRefed<Promise>
AudioContext::Close(ErrorResult& aRv)
{
  nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(GetParentObject());
  nsRefPtr<Promise> promise;
  promise = Promise::Create(parentObject, aRv);
  if (aRv.Failed()) {
    return nullptr;
  }

  if (mIsOffline) {
    promise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
    return promise.forget();
  }

  if (mAudioContextState == AudioContextState::Closed) {
    promise->MaybeResolve(NS_ERROR_DOM_INVALID_STATE_ERR);
    return promise.forget();
  }

  mCloseCalled = true;

  if (Destination()) {
    Destination()->DestroyAudioChannelAgent();
  }

  mPromiseGripArray.AppendElement(promise);

  // This can be called when freeing a document, and the streams are dead at
  // this point, so we need extra null-checks.
  MediaStream* ds = DestinationStream();
  if (ds) {
    Graph()->ApplyAudioContextOperation(ds->AsAudioNodeStream(),
                                        AudioContextOperation::Close, promise);

    if (ds) {
      ds->BlockStreamIfNeeded();
    }
  }
  return promise.forget();
}
void StaticMap::SendObjectEffects(Player *player)
{
    /*
    EffectList::iterator itrEList;
    ObjectEffect *effect;

    //this shouldn't do anything yet
    if (m_Effects)
    { 
        for (itrEList = m_Effects->begin(); itrEList < m_Effects->end(); ++itrEList) 
        {
            effect = (*itrEList);
            effect->TimeStamp = GetNet7TickCount();
            effect->GameID = GameID();
            effect->EffectID = m_ObjectMgr->GetAvailableSectorID();
            // Ignore the effect if the DescID is zero
            if (effect->EffectDescID > 0)
            {
                LogMessage("Sending effect for %s [%d]\n",Name(), effect->EffectDescID);
                connection->SendObjectEffect(effect);
            }
        }
    }*/

    if (ObjectType() == OT_STARGATE) //initial state of stargates - closed
    {
        if (player->FromSector() == Destination())
        {
            //if we came from this stargate it should be open to start off with            
            player->SendActivateNextRenderState(GameID(), 1);
        }
        else
        {
            player->SendActivateRenderState(GameID(), 1); //gate graphics activate
            player->SendActivateNextRenderState(GameID(), 3);
        }
    }
    else
    {
        // Send ActivateRenderState packet(s)
        long rs = RenderState();
        while (rs)
        {
            if (rs & 1)
            {
                player->SendActivateRenderState(GameID(), 1);
            }
            rs >>= 1;
        }
    }
}
Exemple #13
0
void cMonster::InStateIdle(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	if (m_PathfinderActivated)
	{
		return;  // Still getting there
	}

	m_IdleInterval += a_Dt;

	if (m_IdleInterval > std::chrono::seconds(1))
	{
		// At this interval the results are predictable
		int rem = m_World->GetTickRandomNumber(6) + 1;
		m_IdleInterval -= std::chrono::seconds(1);  // So nothing gets dropped when the server hangs for a few seconds

		Vector3d Dist;
		Dist.x = static_cast<double>(m_World->GetTickRandomNumber(10)) - 5.0;
		Dist.z = static_cast<double>(m_World->GetTickRandomNumber(10)) - 5.0;

		if ((Dist.SqrLength() > 2)  && (rem >= 3))
		{

			Vector3d Destination(GetPosX() + Dist.x, GetPosition().y, GetPosZ() + Dist.z);

			cChunk * Chunk = a_Chunk.GetNeighborChunk(static_cast<int>(Destination.x), static_cast<int>(Destination.z));
			if ((Chunk == nullptr) || !Chunk->IsValid())
			{
				return;
			}

			BLOCKTYPE BlockType;
			NIBBLETYPE BlockMeta;
			int RelX = static_cast<int>(Destination.x) - Chunk->GetPosX() * cChunkDef::Width;
			int RelZ = static_cast<int>(Destination.z) - Chunk->GetPosZ() * cChunkDef::Width;
			int YBelowUs = static_cast<int>(Destination.y) - 1;
			if (YBelowUs >= 0)
			{
				Chunk->GetBlockTypeMeta(RelX, YBelowUs, RelZ, BlockType, BlockMeta);
				if (BlockType != E_BLOCK_STATIONARY_WATER)  // Idle mobs shouldn't enter water on purpose
				{
					MoveToPosition(Destination);
				}
			}
		}
	}
}
already_AddRefed<Promise>
AudioContext::Resume(ErrorResult& aRv)
{
  nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(GetParentObject());
  RefPtr<Promise> promise;
  promise = Promise::Create(parentObject, aRv);
  if (aRv.Failed()) {
    return nullptr;
  }

  if (mIsOffline) {
    promise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
    return promise.forget();
  }

  if (mAudioContextState == AudioContextState::Closed ||
      mCloseCalled) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
    return promise.forget();
  }

  if (mAudioContextState == AudioContextState::Running) {
    promise->MaybeResolve(JS::UndefinedHandleValue);
    return promise.forget();
  }

  Destination()->Resume();

  nsTArray<MediaStream*> streams;
  // If mSuspendCalled is false then we already resumed all our streams,
  // so don't resume them again (since suspend(); resume(); resume(); should
  // be OK). But we still need to do ApplyAudioContextOperation
  // to ensure our new promise is resolved.
  if (mSuspendCalled) {
    streams = GetAllStreams();
  }
  mPromiseGripArray.AppendElement(promise);
  Graph()->ApplyAudioContextOperation(DestinationStream()->AsAudioNodeStream(),
                                      streams,
                                      AudioContextOperation::Resume, promise);

  mSuspendCalled = false;

  return promise.forget();
}
Exemple #15
0
void Path::findPath(int x, int y)
{
	Destination *dest = Path::findNeighbors(x, y);
	Destination * current = &Destination(x, y, 0, 0);
	if (dest == NULL) {
		for (int i = 0; i < signed(destinations->size()); i++)
			destinations->at(i)->Print();
		std::cout << "Could not find location" << std::endl;
		return;
	}
	Direction direction;
	int distance = 0;
	for (int i = 0; i < 120; i++)
	{
		direction = findDirection(current->x, current->y, dest->x, dest->y);
		distance = findDistance(current->x, current->y, dest->x, dest->y);
		//const char *arr[] = {"Left", "Right", "Up", "Down"};
		//std::cout << "Going " << arr[direction] << "distance " << distance << std::endl;
		roadMap.push_back(new Destination(dest->x, dest->y, direction, distance * GRANULARITY));
		current = dest;
		int random = rand() % current->neighbors.size();
		dest = current->neighbors.at(random);
	}
}
//Called every time this StaticMap is targeted.
void StaticMap::OnTargeted(Player *player)
{
    player->BlankVerbs();

    float docking_range = DOCKING_RANGE;

    if (player->ShipIndex()->GetIsIncapacitated())
    {
        docking_range = -1.0f;
    }

    switch (ObjectType())
    {
    case OT_STATION:
		player->AddVerb(VERBID_DOCK, docking_range);
        player->AddVerb(VERBID_REGISTER, DOCKING_RANGE);
        break;

    case OT_STARGATE:
        if (Destination() > 0)
        {
			//check for faction.
			long faction_id = GetFactionID();
			bool class_specific = GetClassSpecific();

			if (player->GetOverrideFaction()) //allow devs and testers to override faction/class restrictions
			{
				player->AddVerb(VERBID_GATE, docking_range);
			}
			else if (class_specific)
			{
				if (faction_id == player->GetFactionID() || faction_id < 1)
				{
					player->AddVerb(VERBID_GATE, docking_range);
				}
			}
			else if (faction_id > 0)
			{
				if (player->GetFactionStanding(this) >= 0.0f) //allow gate travel if faction is greater than zero
				{
					player->AddVerb(VERBID_GATE, docking_range);
				}
			}
			else
			{
				player->AddVerb(VERBID_GATE, docking_range);
			}
        }
		break;

    case OT_PLANET:
        if (Destination() > 0)
        {
            player->AddVerb(VERBID_LAND, docking_range);
        }
        break;
        
    default:
        break;
    };
}
double
AudioContext::CurrentTime() const
{
  return MediaTimeToSeconds(Destination()->Stream()->GetCurrentTime()) +
      ExtraCurrentTime();
}
Perpendiculaire::Perpendiculaire(string nom, char key, ofVec2f * _pointOrigine, ofVec2f * _pointDestination, float _position) :
    Perpendiculaire(nom, key, _position)
{
    Origine(_pointOrigine);
    Destination(_pointDestination);
}
Exemple #19
0
void BattleSpellCastParameters::aimToHex(const BattleHex& destination)
{
	destinations.push_back(Destination(destination));
}
Exemple #20
0
static void
ct_exit(dbref player, dbref i, warn_type flags)
{
    dbref j, src, dst;
    int count = 0;
    int lt;

    /* i must be an exit, must be in a valid room, and must lead to a
     * different room
     * Remember, for exit i, Exits(i) = source room
     * and Location(i) = destination room
     */

    dst = Destination(i);
    if ((flags & W_EXIT_UNLINKED) && (dst == NOTHING))
        complain(player, i, "exit-unlinked",
                 T("exit is unlinked; anyone can steal it"));

    if ((flags & W_EXIT_UNLINKED) && dst == AMBIGUOUS) {
        ATTR *a;
        const char *var = "DESTINATION";
        a = atr_get(i, "DESTINATION");
        if (!a)
            a = atr_get(i, "EXITTO");
        if (a)
            var = "EXITTO";
        if (!a)
            complain(player, i, "exit-unlinked",
                     T("Variable exit has no %s attribute"), var);
        else {
            const char *x = atr_value(a);
            if (!x || !*x)
                complain(player, i, "exit-unlinked",
                         T("Variable exit has empty %s attribute"), var);
        }
    }

    if (!Dark(i)) {
        if (flags & W_EXIT_MSGS) {
            lt = warning_lock_type(getlock(i, Basic_Lock));
            if ((lt & W_UNLOCKED) &&
                    (!atr_get(i, "OSUCCESS") || !atr_get(i, "ODROP") ||
                     !atr_get(i, "SUCCESS")))
                complain(player, i, "exit-msgs",
                         T("possibly unlocked exit missing succ/osucc/odrop"));
            if ((lt & W_LOCKED) && !atr_get(i, "FAILURE"))
                complain(player, i, "exit-msgs",
                         T("possibly locked exit missing fail"));
        }
        if (flags & W_EXIT_DESC) {
            if (!atr_get(i, "DESCRIBE"))
                complain(player, i, "exit-desc", T("exit is missing description"));
        }
    }
    src = Source(i);
    if (!GoodObject(src) || !IsRoom(src))
        return;
    if (src == dst)
        return;
    /* Don't complain about exits linked to HOME or variable exits. */
    if (!GoodObject(dst))
        return;

    for (j = Exits(dst); GoodObject(j); j = Next(j))
        if (Location(j) == src) {
            if (!(flags & W_EXIT_MULTIPLE))
                return;
            else
                count++;
        }
    if ((count == 0) && (flags & W_EXIT_ONEWAY))
        complain(player, i, "exit-oneway", T("exit has no return exit"));
    else if ((count > 1) && (flags & W_EXIT_MULTIPLE))
        complain(player, i, "exit-multiple",
                 T("exit has multiple (%d) return exits"), count);
}
TMvSessionAction::TMvSessionAction(TActionLog *Log,
  UnicodeString AFileName, UnicodeString ADestination) :
  TFileLocationSessionAction(Log, laMv, AFileName)
{
  Destination(ADestination);
}
MultiplesTangentes::MultiplesTangentes(string nom, char key, ofVec2f * _pointOrigine, ofVec2f * _pointDestination) :
    MultiplesTangentes(nom, key)
{
    Origine(_pointOrigine);
    Destination(_pointDestination);
}
Exemple #23
0
void vehicle::UpdateRotation()
{
    k = Angle(Destination() - pos);
}
Exemple #24
0
void Log::reset() {
  cerr_log_ = Destination(new rlog::StdioNode(STDERR_FILENO, DEFAULT_FLAGS));
  cout_log_ = Destination(new rlog::StdioNode(STDOUT_FILENO, DEFAULT_FLAGS));
  files_.clear();
}
MediaStreamGraph*
AudioContext::Graph() const
{
  return Destination()->Stream()->Graph();
}
MediaStream*
AudioContext::DestinationStream() const
{
  return Destination()->Stream();
}
Exemple #27
0
bool vehicle::Progress(double time)
{
	if (((p.p.size() == 3) && (progr >= targetProgr)) || (p.p.size() == 2))
	{
		//3 - end, drove over targetProgr
		//2 - jumped over targetProgr to end of road
		RemList();
		return 1;//end
	}

	
	double sNow = speed*(double(time)/1000);
	
	//lanes
	if (changingLaneFrom != -1)
	{
		//continue changing lane
		double now = sNow * 0.5;
		double left = 1 - changingLaneProgr;

		bool end = 0;

		if (now >= left)
		{
			now = left;
			end = 1;
		}

		changingLaneProgr += now;
		
		int rot;
		if (lNr > changingLaneFrom)
			rot = 90;
		else
			rot = -90;
		k += rot;
		Drive(now);
		k -= rot;

		if (end)
		{
			changingLaneFrom = -1;
		}
	}
	else
	{
		//look for better lane
		if (BetterAtLane(lNr - 1))
			ChangeLane(lNr - 1);
		else if (BetterAtLane(lNr + 1))
			ChangeLane(lNr + 1);
	}

	double dist = Length(pos, Destination());

	
	if (dist <= sNow)
	{
		Drive(dist);

		RemList();		
		p.Skip();		
				
		progr = c->GetRoadProgress(p.Prev(), p.Now(), pos);

		AddList();

		if (p.p.size() >= 3)
			UpdateRotation();

		//add speed control in here too
				
		if (speed != 0)
		{
			//reduce avail
			double leftDist = sNow - dist;	
			int leftTime = int((leftDist / (speed)) * 1000);
			
			return Progress(leftTime);
		}
	}
	else
	{
		Drive(sNow);
		
		double left;//distance to obstacle
		left = obs.d;

		if (c->Crossroad(p.Now()) && !c->LAvailable(p.Now(), p.Prev()))
		{
			double distToCrossing = c->DistanceToCrossroad(p.Prev(), p.Now(), pos) - vM->l;
			left = min(left, distToCrossing);
		}
				
		/*
		(0; 1) - Brake
		(1; 2) - nieko
		(2; +inf) - Accelerate
		*/
		const double bestDist = 0.5;
		const double warnDist = 1.5;

		if (left < bestDist)
		{
			//increase distance
			speed = 0;
			Brake(time);
		}
		else if (left < warnDist)
		{
			speed = obs.speed;
		}
		else if (left > bestDist)
		{
			Accelerate(time);
		}

	}
		

	return 0;
}
Exemple #28
0
//---------------------------------------------------------------------------
TMvSessionAction::TMvSessionAction(TActionLog * Log,
    const UnicodeString & FileName, const UnicodeString & ADestination) :
  TFileLocationSessionAction(Log, laMv, FileName)
{
  Destination(ADestination);
}
Exemple #29
0
Log::Log() {
  cout_log_ = Destination(new rlog::StdioNode(STDOUT_FILENO, DEFAULT_FLAGS));
  cerr_log_ = Destination(new rlog::StdioNode(STDERR_FILENO, DEFAULT_FLAGS));
}