Exemplo n.º 1
0
void C4Effect::Kill()
{
	// active?
	C4Effect *pLastRemovedEffect=NULL;
	if (IsActive())
		// then temp remove all higher priority effects
		TempRemoveUpperEffects(false, &pLastRemovedEffect);
	else
		// otherwise: temp reactivate before real removal
		// this happens only if a lower priority effect removes an upper priority effect in its add- or removal-call
		if (iPriority!=1) CallStart(C4FxCall_TempAddForRemoval, C4Value(), C4Value(), C4Value(), C4Value());
	// remove this effect
	int32_t iPrevPrio = iPriority; SetDead();
	if (CallStop(C4FxCall_Normal, false) == C4Fx_Stop_Deny)
		// effect denied to be removed: recover
		iPriority = iPrevPrio;
	// reactivate other effects
	TempReaddUpperEffects(pLastRemovedEffect);
	// Update OnFire cache
	if (Target && WildcardMatch(C4Fx_AnyFire, GetName()))
		if (!Get(C4Fx_AnyFire))
			Target->SetOnFire(false);
	if (IsDead() && !GetCallbackScript())
		Call(P_Destruction, &C4AulParSet(C4FxCall_Normal));
}
Exemplo n.º 2
0
BOOL WINAPI duFlash::Stop()
{
	if (m_pFlash == NULL)
		return FALSE;

	CallStop();
	return TRUE;
}
Exemplo n.º 3
0
void C4Effect::TempRemoveUpperEffects(bool fTempRemoveThis, C4Effect **ppLastRemovedEffect)
{
	if (Target && !Target->Status) return; // this will be invalid!
	// priority=1: no callbacks
	if (iPriority == 1) return;
	// remove from high to low priority
	// recursive implementation...
	C4Effect *pEff = pNext;
		while (pEff) if (pEff->IsActive()) break; else pEff = pEff->pNext;
	// temp remove active effects with higher priority
	if (pEff) pEff->TempRemoveUpperEffects(true, ppLastRemovedEffect);
	// temp remove this
	if (fTempRemoveThis)
	{
		FlipActive();
		// Update OnFire cache
		if (Target && WildcardMatch(C4Fx_AnyFire, GetName()))
			if (!Get(C4Fx_AnyFire))
				Target->SetOnFire(false);
		// temp callbacks only for higher priority effects
		if (iPriority!=1) CallStop(C4FxCall_Temp, true);
		if (!*ppLastRemovedEffect) *ppLastRemovedEffect = this;
	}
}
Exemplo n.º 4
0
void C4Effect::ClearAll(int32_t iClearFlag)
{
	// simply remove access all effects recursively, and do removal calls
	// this does not regard lower-level effects being added in the removal calls,
	// because this could hang the engine with poorly coded effects
	if (pNext) pNext->ClearAll(iClearFlag);
	if ((Target && !Target->Status) || IsDead()) return;
	int32_t iPrevPrio = iPriority;
	SetDead();
	if (CallStop(iClearFlag, false) == C4Fx_Stop_Deny)
	{
		// this stop-callback might have deleted the object and then denied its own removal
		// must not modify self in this case...
		if (Target && !Target->Status) return;
		// effect denied to be removed: recover it
		iPriority = iPrevPrio;
	}
	// Update OnFire cache
	if (Target && WildcardMatch(C4Fx_AnyFire, GetName()) && IsDead())
		if (!Get(C4Fx_AnyFire))
			Target->SetOnFire(false);
	if (IsDead() && !GetCallbackScript())
		Call(P_Destruction, &C4AulParSet(iClearFlag));
}
Exemplo n.º 5
0
  void SessionFactory::CreateSession(Node *node, const Id &session_id,
      SessionType type, AuthFactory::AuthType auth_type,
      const QSharedPointer<KeyShare> &public_keys)
  {
    CreateRound cr;
    switch(type) {
      case NULL_ROUND:
        cr = &TCreateRound<NullRound>;
        break;
      case SHUFFLE:
        cr = &TCreateRound<ShuffleRound>;
        break;
      case BULK:
        cr = &TCreateRound<BulkRound>;
        break;
      case REPEATING_BULK:
        cr = &TCreateRound<RepeatingBulkRound>;
        break;
      case CSBULK:
        cr = &TCreateBulkRound<CSBulkRound, NeffKeyShuffleRound>;
        break;
      case NEFF_SHUFFLE:
        cr = &TCreateRound<NeffShuffleRound>;
      case BLOG_DROP_REACTIVE:
        cr = TCreateBlogDropRound<Parameters::ParameterType_CppECHashingProduction,
           NeffShuffleRound, false>;
        break;
      case BLOG_DROP_PROACTIVE:
        cr = TCreateBlogDropRound<Parameters::ParameterType_CppECHashingProduction,
           NeffShuffleRound, true>;
        break;
      default:
        qFatal("Invalid session type");
    }

    QSharedPointer<IAuthenticate> authe(AuthFactory::CreateAuthenticate(
          node, auth_type, public_keys));

    Session *session = new Session(node->GetGroupHolder(), authe, session_id,
        node->GetNetwork(), cr);

    QObject::connect(node->GetOverlay().data(), SIGNAL(Disconnecting()),
        session, SLOT(CallStop()));

    QSharedPointer<Session> psession(session);
    session->SetSharedPointer(psession);
    node->GetSessionManager().AddSession(psession);

    psession->SetSink(node->GetSink().data());
    if(node->GetPrivateIdentity().GetLocalId() ==
        node->GetGroupHolder()->GetGroup().GetLeader())
    {
      QSharedPointer<IAuthenticator> autho(AuthFactory::CreateAuthenticator(
            node, auth_type, public_keys));
      QSharedPointer<SessionLeader> sl(new SessionLeader(
            node->GetGroupHolder()->GetGroup(), node->GetPrivateIdentity(),
            node->GetNetwork(), psession, autho));
      node->GetSessionManager().AddSessionLeader(sl);
      sl->Start();
    } else {
      psession->Start();
    }
  }