예제 #1
0
파일: failures.c 프로젝트: chazu/btmux
static void mech_srec_event(MUXEVENT * e)
{
	MECH *mech = (MECH *) e->data;
	int val = (int) e->data2;
	int vt = val / 256;

	switch (vt) {
	case 0:
		MechTacRange(mech) = val;
		if(!Destroyed(mech))
			mech_notify(mech, MECHALL,
						"Your tactical scanners are operational again.");
		break;
	case 1:
		MechLRSRange(mech) = val;
		if(!Destroyed(mech))
			mech_notify(mech, MECHALL,
						"Your long-range scanners are operational again.");
		break;
	case 2:
		MechScanRange(mech) = val;
		if(!Destroyed(mech))
			mech_notify(mech, MECHALL,
						"Your scanners are operational again.");
		break;
	}
}
예제 #2
0
bool
TextComposition::MaybeDispatchCompositionUpdate(const WidgetTextEvent* aEvent)
{
  if (Destroyed()) {
    return false;
  }

  if (mLastData == aEvent->theText) {
    return true;
  }

  WidgetCompositionEvent compositionUpdate(aEvent->mFlags.mIsTrusted,
                                           NS_COMPOSITION_UPDATE,
                                           aEvent->widget);
  compositionUpdate.time = aEvent->time;
  compositionUpdate.timeStamp = aEvent->timeStamp;
  compositionUpdate.data = aEvent->theText;
  compositionUpdate.mFlags.mIsSynthesizedForTests =
    aEvent->mFlags.mIsSynthesizedForTests;

  nsEventStatus status = nsEventStatus_eConsumeNoDefault;
  if (aEvent->mFlags.mIsSynthesizedForTests &&
      (mIsRequestingCommit || mIsRequestingCancel)) {
    // At emulating commit/cancel request, compositionupdate should be
    // dispatched via widget since it's more similar path to native event.
    aEvent->widget->DispatchEvent(&compositionUpdate, status);
  } else {
    mLastData = compositionUpdate.data;
    EventDispatcher::Dispatch(mNode, mPresContext,
                              &compositionUpdate, nullptr, &status, nullptr);
  }
  return !Destroyed();
}
예제 #3
0
bool
TextComposition::MaybeDispatchCompositionUpdate(
                   const WidgetCompositionEvent* aCompositionEvent)
{
  if (Destroyed()) {
    return false;
  }

  if (mLastData == aCompositionEvent->mData) {
    return true;
  }

  WidgetCompositionEvent compositionUpdate(aCompositionEvent->mFlags.mIsTrusted,
                                           NS_COMPOSITION_UPDATE,
                                           aCompositionEvent->widget);
  compositionUpdate.time = aCompositionEvent->time;
  compositionUpdate.timeStamp = aCompositionEvent->timeStamp;
  compositionUpdate.mData = aCompositionEvent->mData;
  compositionUpdate.mFlags.mIsSynthesizedForTests =
    aCompositionEvent->mFlags.mIsSynthesizedForTests;

  nsEventStatus status = nsEventStatus_eConsumeNoDefault;
  mLastData = compositionUpdate.mData;
  EventDispatcher::Dispatch(mNode, mPresContext,
                            &compositionUpdate, nullptr, &status, nullptr);
  return !Destroyed();
}
예제 #4
0
파일: XosXAtom.hpp 프로젝트: medusade/mxde
    ///////////////////////////////////////////////////////////////////////
    ///  Function: AttachIntern
    ///
    ///    Author: $author$
    ///      Date: 5/17/2012
    ///////////////////////////////////////////////////////////////////////
    virtual Atom AttachIntern
    (Display* xDisplay,
     const char* name, 
     Bool onlyExists = False,
     bool onlyDetached = false)
    {
        tAttachedTo attached = (tAttachedTo)(vUnattached);
        tAttachedTo detached;
        XosError error;

        if (!(xDisplay) || !(name))
            return attached;

        if ((error = Destroyed(onlyDetached)))
            return attached;

        XOS_DBT(("() XInternAtom(%p, \"%s\", %s)...\n", xDisplay, name, (onlyExists)?("True"):("False")));

        if ((tAttachedTo)(vUnattached) != (detached = XInternAtom(xDisplay, name, onlyExists)))
            attached = Attach(xDisplay, detached);
        else
        XOS_DBE(("() failed on XInternAtom(%p, \"%s\", %s)\n", xDisplay, name, (onlyExists)?("True"):("False")));

        return attached;
    }
예제 #5
0
bool
TextComposition::IsValidStateForComposition(nsIWidget* aWidget) const
{
  return !Destroyed() && aWidget && !aWidget->Destroyed() &&
         mPresContext->GetPresShell() &&
         !mPresContext->GetPresShell()->IsDestroying();
}
// 보스를 움직이기:
// 보스를 구성하는 모든 적기에 대하여 순서대로 처리를 수행함.
void MoveComplexEnemy(COMPLEX_ENEMY* ce) {
	for (int i=0; i<ce->NumPart; i++) {

		// 적기를 움직이기:
		// 구체적인 처리는 MoveEnemy함수에서 수행함.
		MoveEnemy(ce->Part[i]);

		// 적기를 표시하기:
		// 모든 부품이 하나가 되어 움직이도록
		// 부품의 좌표를 보스 좌표로부터 상대 위치가 되도록 사용함.
		// 보스 전체를 움직이기 위해서는 ce->X와 ce->Y를 갱신함.
		// 구체적인 처리는 DrawEnemy함수에서 수행함.
		DrawEnemy(ce->Part[i],
			ce->Part[i]->X+ce->X, ce->Part[i]->Y+ce->Y);

		// 적기의 파괴:
		// 판정과 파괴의 구체적인 처리는 각각
		// Destroyed,DeleteEnemy함수에서 수행함.
		if (Destroyed(ce->Part[i])) {
			DeleteEnemy(ce->Part[i]);

			// 보스 전체의 파괴:
			// 치명적인 부품이 파괴되었을 때는
			// 보스 전체를 파괴시킴.
			if (ce->Fatal[i]) DeleteEnemy(ce);
		}
	}
}
예제 #7
0
 ///////////////////////////////////////////////////////////////////////
 //  Destructor: ~cPThreadMutex
 //
 //      Author: $author$
 //        Date: 3/20/2011
 ///////////////////////////////////////////////////////////////////////
 virtual ~cPThreadMutex()
 {
     eError error;
     if ((error = Destroyed()))
     {
         c_DB_ERROR("() failed on Destroyed()");
         throw (error);
     }
 }
예제 #8
0
파일: failures.c 프로젝트: chazu/btmux
static void mech_rrec_event(MUXEVENT * e)
{
	MECH *mech = (MECH *) e->data;
	int val = (int) e->data2;

	MechRadioRange(mech) += val;
	if(!Destroyed(mech) && val == MechRadioRange(mech))
		mech_notify(mech, MECHALL, "Your radio is now operational again.");
}
예제 #9
0
bool
hnStatus::Dead()
{
	if ( Destroyed() )
		return true;
	if ( m_undead )
		return true;
	
	return false;
}
예제 #10
0
nsresult
TextComposition::RequestToCommit(nsIWidget* aWidget, bool aDiscard)
{
  // If this composition is already requested to be committed or canceled,
  // or has already finished in IME, we don't need to request it again because
  // request from this instance shouldn't cause committing nor canceling current
  // composition in IME, and even if the first request failed, new request
  // won't success, probably.  And we shouldn't synthesize events for
  // committing or canceling composition twice or more times.
  if (!CanRequsetIMEToCommitOrCancelComposition()) {
    return NS_OK;
  }

  RefPtr<TextComposition> kungFuDeathGrip(this);
  const nsAutoString lastData(mLastData);

  {
    AutoRestore<bool> saveRequestingCancel(mIsRequestingCancel);
    AutoRestore<bool> saveRequestingCommit(mIsRequestingCommit);
    if (aDiscard) {
      mIsRequestingCancel = true;
      mIsRequestingCommit = false;
    } else {
      mIsRequestingCancel = false;
      mIsRequestingCommit = true;
    }
    // FYI: CompositionEvents caused by a call of NotifyIME() may be
    //      discarded by PresShell if it's not safe to dispatch the event.
    nsresult rv =
      aWidget->NotifyIME(IMENotification(aDiscard ?
                                           REQUEST_TO_CANCEL_COMPOSITION :
                                           REQUEST_TO_COMMIT_COMPOSITION));
    if (NS_WARN_IF(NS_FAILED(rv))) {
      return rv;
    }
  }

  mRequestedToCommitOrCancel = true;

  // If the request is performed synchronously, this must be already destroyed.
  if (Destroyed()) {
    return NS_OK;
  }

  // Otherwise, synthesize the commit in content.
  nsAutoString data(aDiscard ? EmptyString() : lastData);
  if (data == mLastData) {
    DispatchCompositionEventRunnable(eCompositionCommitAsIs, EmptyString(),
                                     true);
  } else {
    DispatchCompositionEventRunnable(eCompositionCommit, data, true);
  }
  return NS_OK;
}
예제 #11
0
nsresult
HTMLEditor::DoInlineTableEditingAction(const Element& aElement)
{
  nsAutoString anonclass;
  aElement.GetAttr(kNameSpaceID_None, nsGkAtoms::_moz_anonclass, anonclass);

  if (!StringBeginsWith(anonclass, NS_LITERAL_STRING("mozTable"))) {
    return NS_OK;
  }

  RefPtr<Element> tableElement = GetEnclosingTable(mInlineEditedCell);
  int32_t rowCount, colCount;
  nsresult rv = GetTableSize(tableElement, &rowCount, &colCount);
  NS_ENSURE_SUCCESS(rv, rv);

  bool hideUI = false;
  bool hideResizersWithInlineTableUI = (mResizedObject == tableElement);

  if (anonclass.EqualsLiteral("mozTableAddColumnBefore")) {
    InsertTableColumn(1, false);
  } else if (anonclass.EqualsLiteral("mozTableAddColumnAfter")) {
    InsertTableColumn(1, true);
  } else if (anonclass.EqualsLiteral("mozTableAddRowBefore")) {
    InsertTableRow(1, false);
  } else if (anonclass.EqualsLiteral("mozTableAddRowAfter")) {
    InsertTableRow(1, true);
  } else if (anonclass.EqualsLiteral("mozTableRemoveColumn")) {
    DeleteTableColumn(1);
#ifndef DISABLE_TABLE_DELETION
    hideUI = (colCount == 1);
#endif
  } else if (anonclass.EqualsLiteral("mozTableRemoveRow")) {
    DeleteTableRow(1);
#ifndef DISABLE_TABLE_DELETION
    hideUI = (rowCount == 1);
#endif
  } else {
    return NS_OK;
  }

  // InsertTableRow might causes reframe
  if (Destroyed()) {
    return NS_OK;
  }

  if (hideUI) {
    HideInlineTableEditingUI();
    if (hideResizersWithInlineTableUI) {
      HideResizers();
    }
  }

  return NS_OK;
}
예제 #12
0
void mech_recovery_event(EVENT * e)
{
    MECH *mech = (MECH *) e->data;

    if (Destroyed(mech) || !Uncon(mech))
	return;
    if (handlemwconc(mech, 0)) {
	MechStatus(mech) &= ~UNCONSCIOUS;
	mech_notify(mech, MECHALL, "The pilot regains consciousness!");
	return;
    }
}
예제 #13
0
compzillaWindow::~compzillaWindow()
{
    NS_ASSERT_OWNINGTHREAD(compzillaWindow);

    SPEW ("~compzillaWindow %p, xid=%p\n", this, mWindow);

    Destroyed ();

    // FIXME: Do we need this?
    //UnredirectWindow ();

    SPEW ("~compzillaWindow DONE\n");
}
예제 #14
0
void ProlongUncon(MECH * mech, int len)
{
    int l;

    if (Destroyed(mech))
	return;
    if (!Recovering(mech)) {
	MechStatus(mech) |= UNCONSCIOUS;
	MECHEVENT(mech, EVENT_RECOVERY, mech_recovery_event, len, 0);
	return;
    }
    l = event_last_type_data(EVENT_RECOVERY, (void *) mech) + len;
    event_remove_type_data(EVENT_RECOVERY, (void *) mech);
    MECHEVENT(mech, EVENT_RECOVERY, mech_recovery_event, l, 0);
}
예제 #15
0
파일: Entity.cpp 프로젝트: Kortak/MCServer
void cEntity::Destroy(bool a_ShouldBroadcast)
{
	if (!m_IsInitialized)
	{
		return;
	}
	
	if (a_ShouldBroadcast)
	{
		m_World->BroadcastDestroyEntity(*this);
	}

	m_IsInitialized = false;

	Destroyed();
}
예제 #16
0
void validateC3iNetwork(MECH * mech)
{
    MECH *otherMech;
    dbref myTempNetwork[C3I_NETWORK_SIZE];
    int i;
    int networkSize = 0;

    debugC3(tprintf("VALIDATE: %d's C3i network", mech->mynum));

    if (!HasC3i(mech) || Destroyed(mech) || C3iDestroyed(mech)) {
	clearC3iNetwork(mech, 1);

	return;
    }

    if (MechC3iNetworkSize(mech) < 0) {
	clearC3iNetwork(mech, 1);

	return;
    }

    for (i = 0; i < C3I_NETWORK_SIZE; i++) {
	otherMech = getOtherMechInNetwork(mech, i, 0, 0, 0, 0);

	if (!otherMech)
	    continue;

	if (!Good_obj(otherMech->mynum))
	    continue;

	debugC3(tprintf("VALIDATE INFO: %d is now in %d's C3i network",
		otherMech->mynum, mech->mynum));

	myTempNetwork[networkSize++] = otherMech->mynum;
    }

    clearC3iNetwork(mech, 0);

    for (i = 0; i < networkSize; i++)
	MechC3iNetworkElem(mech, i) = myTempNetwork[i];

    MechC3iNetworkSize(mech) = networkSize;

    debugC3(tprintf("VALIDATE INFO: %d's C3i network is %d elements",
	    mech->mynum, MechC3iNetworkSize(mech)));
}
예제 #17
0
VirtScreen::VirtScreen(World * const world_, Player * const player_) :
		w(world_),
		player(player_)
{
	connect(w, SIGNAL(Notify(const QString &)),
		this, SLOT(Notify(const QString &)));
	connect(player, SIGNAL(Notify(const QString &)),
		this, SLOT(Notify(const QString &)));

	connect(w, SIGNAL(GetString(QString &)),
		this, SLOT(PassString(QString &)),
		Qt::DirectConnection);
	connect(player, SIGNAL(GetString(QString &)),
		this, SLOT(PassString(QString &)),
		Qt::DirectConnection);

	connect(player, SIGNAL(Updated()),
		this, SLOT(UpdatePlayer()),
		Qt::DirectConnection);
	connect(w, SIGNAL(ReConnect()),
		this, SLOT(ConnectWorld()),
		Qt::DirectConnection);
	connect(w, SIGNAL(UpdatedAll()),
		this, SLOT(UpdateAll()),
		Qt::DirectConnection);
	connect(w, SIGNAL(Moved(const int)),
		this, SLOT(Move(const int)),
		Qt::DirectConnection);
	ConnectWorld();
	connect(w, SIGNAL(UpdatesEnded()),
		this, SLOT(UpdatesEnd()),
		Qt::DirectConnection);

    connect( player, SIGNAL( Destroyed() ),
            this, SLOT( PlayerDestroyed() ), Qt::DirectConnection );
}
예제 #18
0
void MaybeRecycle(MECH * mech, int wticks)
{
    int nr, dat;

    if (!(Started(mech) && !Destroyed(mech)))
	return;
    nr = NextRecycle(mech);
    UpdateRecycling(mech);
    if (nr < 0)
	MechLWRT(mech) = event_tick;
    if (nr < 0 || nr > ((wticks + 1) * WEAPON_TICK)) {
	dat = MAX(1, wticks * WEAPON_TICK);
	MECHEVENT(mech, EVENT_RECYCLE, mech_recycle_event, dat, 0);
#ifdef WEAPON_RECYCLE_DEBUG
	SendDebug(tprintf("%6d Recycle event for #%d set in %ds.",
		event_tick, mech->mynum, dat));
#endif
    }
#ifdef WEAPON_RECYCLE_DEBUG
    else
	SendDebug(tprintf("%6d Recycle event for #%d exists at %d secs",
		event_tick, mech->mynum, nr));
#endif
}
예제 #19
0
VirtScreen::VirtScreen(World * const world_, Player * const player_) :
        w(world_),
        player(player_),
        settings(home_path + "freg.ini", QSettings::IniFormat),
        previousCommand(settings.value("last_command", "moo").toString())
{
    connect(     w, SIGNAL(Notify(QString)), SLOT(Notify(QString)),
        Qt::DirectConnection);
    connect(player, SIGNAL(Notify(QString)), SLOT(Notify(QString)),
        Qt::DirectConnection);
    connect(player, SIGNAL(ShowFile(QString)), SLOT(DisplayFile(QString)));
    connect(player, SIGNAL(GetFocus(int *, int *, int *)),
        SLOT(ActionXyz(int *, int *, int *)), Qt::DirectConnection);

    connect(     w, SIGNAL(GetString(QString &)),
        SLOT(PassString(QString &)), Qt::DirectConnection);
    connect(player, SIGNAL(GetString(QString &)),
        SLOT(PassString(QString &)), Qt::DirectConnection);

    connect(player, SIGNAL(Updated()), SLOT(UpdatePlayer()),
        Qt::DirectConnection);
    connect(w, SIGNAL(UpdatedAll()), SLOT(UpdateAll()),
        Qt::DirectConnection);
    connect(w, SIGNAL(Moved(int)), SLOT(Move(int)),
        Qt::DirectConnection);
    connect(w, SIGNAL(Updated(int, int, int)), SLOT(Update(int, int, int)),
        Qt::DirectConnection);
    connect(w, SIGNAL(UpdatedAround(int, int, int, int)),
        SLOT(UpdateAround(int, int, int, int)),
        Qt::DirectConnection);
    connect(w, SIGNAL(UpdatesEnded()), SLOT(UpdatesEnd()),
        Qt::DirectConnection);

    connect(player, SIGNAL(Destroyed()), SLOT(DeathScreen()),
        Qt::DirectConnection );
}
예제 #20
0
파일: mech.c3.misc.c 프로젝트: chazu/btmux
MECH *getMechInTempNetwork(int wIdx, dbref * myNetwork, int networkSize)
{
	MECH *tempMech;
	dbref refOtherMech;

	if((wIdx > networkSize) || (wIdx < 0))
		return NULL;

	refOtherMech = myNetwork[wIdx];

	if(refOtherMech > 0) {
		tempMech = getMech(refOtherMech);

		if(!tempMech)
			return NULL;

		if(Destroyed(tempMech))
			return NULL;

		return tempMech;
	}

	return NULL;
}
예제 #21
0
nsresult
TextComposition::RequestToCommit(nsIWidget* aWidget, bool aDiscard)
{
  // If this composition is already requested to be committed or canceled,
  // we don't need to request it again because even if the first request
  // failed, new request won't success, probably.  And we shouldn't synthesize
  // events for committing or canceling composition twice or more times.
  if (mRequestedToCommitOrCancel) {
    return NS_OK;
  }

  nsRefPtr<TextComposition> kungFuDeathGrip(this);
  const nsAutoString lastData(mLastData);

  {
    AutoRestore<bool> saveRequestingCancel(mIsRequestingCancel);
    AutoRestore<bool> saveRequestingCommit(mIsRequestingCommit);
    if (aDiscard) {
      mIsRequestingCancel = true;
      mIsRequestingCommit = false;
    } else {
      mIsRequestingCancel = false;
      mIsRequestingCommit = true;
    }
    if (!mIsSynthesizedForTests) {
      // FYI: CompositionEvent and TextEvent caused by a call of NotifyIME()
      //      may be discarded by PresShell if it's not safe to dispatch the
      //      event.
      nsresult rv =
        aWidget->NotifyIME(IMENotification(aDiscard ?
                                             REQUEST_TO_CANCEL_COMPOSITION :
                                             REQUEST_TO_COMMIT_COMPOSITION));
      if (rv == NS_ERROR_NOT_IMPLEMENTED) {
        return rv;
      }
      if (NS_WARN_IF(NS_FAILED(rv))) {
        return rv;
      }
    } else {
      // Emulates to commit or cancel the composition
      // FYI: These events may be discarded by PresShell if it's not safe to
      //      dispatch the event.
      nsCOMPtr<nsIWidget> widget(aWidget);
      nsAutoString commitData(aDiscard ? EmptyString() : lastData);
      bool changingData = lastData != commitData;

      WidgetTextEvent textEvent(true, NS_TEXT_TEXT, widget);
      textEvent.theText = commitData;
      textEvent.mFlags.mIsSynthesizedForTests = true;

      MaybeDispatchCompositionUpdate(&textEvent);

      // If changing the data or committing string isn't empty, we need to
      // dispatch text event for setting the composition string without
      // IME selection.
      if (!Destroyed() && !widget->Destroyed() &&
          (changingData || !commitData.IsEmpty())) {
        nsEventStatus status = nsEventStatus_eIgnore;
        widget->DispatchEvent(&textEvent, status);
      }

      if (!Destroyed() && !widget->Destroyed()) {
        nsEventStatus status = nsEventStatus_eIgnore;
        WidgetCompositionEvent endEvent(true, NS_COMPOSITION_END, widget);
        endEvent.data = commitData;
        endEvent.mFlags.mIsSynthesizedForTests = true;
        widget->DispatchEvent(&endEvent, status);
      }
    }
  }

  mRequestedToCommitOrCancel = true;

  // If the request is performed synchronously, this must be already destroyed.
  if (Destroyed()) {
    return NS_OK;
  }

  // Otherwise, synthesize the commit in content.
  nsAutoString data(aDiscard ? EmptyString() : lastData);
  bool changingData = lastData != data;
  if (changingData) {
    DispatchCompositionEventRunnable(NS_COMPOSITION_UPDATE, data, true);
  }
  // If the last composition string and new data are different, we need to
  // dispatch text event for removing IME selection.  However, if the commit
  // string is empty string and it's not changed from the last data, we don't
  // need to dispatch text event.
  if (changingData || !data.IsEmpty()) {
    DispatchCompositionEventRunnable(NS_TEXT_TEXT, data, true);
  }
  DispatchCompositionEventRunnable(NS_COMPOSITION_END, data, true);

  return NS_OK;
}
예제 #22
0
void
TextComposition::DispatchEvent(WidgetGUIEvent* aEvent,
                               nsEventStatus* aStatus,
                               EventDispatchingCallback* aCallBack,
                               bool aIsSynthesized)
{
  if (Destroyed()) {
    *aStatus = nsEventStatus_eConsumeNoDefault;
    return;
  }

  // If this instance has requested to commit or cancel composition but
  // is not synthesizing commit event, that means that the IME commits or
  // cancels the composition asynchronously.  Typically, iBus behaves so.
  // Then, synthesized events which were dispatched immediately after
  // the request has already committed our editor's composition string and
  // told it to web apps.  Therefore, we should ignore the delayed events.
  if (mRequestedToCommitOrCancel && !aIsSynthesized) {
    *aStatus = nsEventStatus_eConsumeNoDefault;
    return;
  }

  // IME may commit composition with empty string for a commit request or
  // with non-empty string for a cancel request.  We should prevent such
  // unexpected result.  E.g., web apps may be confused if they implement
  // autocomplete which attempts to commit composition forcibly when the user
  // selects one of suggestions but composition string is cleared by IME.
  // Note that most Chinese IMEs don't expose actual composition string to us.
  // They typically tell us an IDEOGRAPHIC SPACE or empty string as composition
  // string.  Therefore, we should hack it only when:
  // 1. committing string is empty string at requesting commit but the last
  //    data isn't IDEOGRAPHIC SPACE.
  // 2. non-empty string is committed at requesting cancel.
  if (!aIsSynthesized && (mIsRequestingCommit || mIsRequestingCancel)) {
    nsString* committingData = nullptr;
    switch (aEvent->message) {
      case NS_COMPOSITION_UPDATE:
      case NS_COMPOSITION_END:
        committingData = &aEvent->AsCompositionEvent()->data;
        break;
      case NS_TEXT_TEXT:
        committingData = &aEvent->AsTextEvent()->theText;
        break;
      default:
        NS_WARNING("Unexpected event comes during committing or "
                   "canceling composition");
        break;
    }
    if (committingData) {
      if (mIsRequestingCommit && committingData->IsEmpty() &&
          mLastData != IDEOGRAPHIC_SPACE) {
        committingData->Assign(mLastData);
      } else if (mIsRequestingCancel && !committingData->IsEmpty()) {
        committingData->Truncate();
      }

      if (aEvent->message == NS_COMPOSITION_UPDATE) {
        // If committing string is not different from the last data,
        // we don't need to dispatch this.
        if (committingData->Equals(mLastData)) {
          return;
        }
      } else if (aEvent->message == NS_TEXT_TEXT) {
        // If committing string is different from the last data,
        // we need to dispatch compositionupdate before dispatching text event.
        if (!MaybeDispatchCompositionUpdate(aEvent->AsTextEvent())) {
          NS_WARNING("Dispatching compositionupdate caused destroying");
          return;
        }
      }
    }
  }

  if (aEvent->message == NS_COMPOSITION_UPDATE) {
    mLastData = aEvent->AsCompositionEvent()->data;
  }

  EventDispatcher::Dispatch(mNode, mPresContext,
                            aEvent, nullptr, aStatus, aCallBack);

  if (NS_WARN_IF(Destroyed())) {
    return;
  }

  // Emulate editor behavior of text event handler if no editor handles
  // composition/text events.
  if (aEvent->message == NS_TEXT_TEXT && !HasEditor()) {
    EditorWillHandleTextEvent(aEvent->AsTextEvent());
    EditorDidHandleTextEvent();
  }

#ifdef DEBUG
  else if (aEvent->message == NS_COMPOSITION_END) {
    MOZ_ASSERT(!mIsComposing, "Why is the editor still composing?");
    MOZ_ASSERT(!HasEditor(), "Why does the editor still keep to hold this?");
  }
#endif // #ifdef DEBUG

  // Notify composition update to widget if possible
  NotityUpdateComposition(aEvent);
}
예제 #23
0
 ///////////////////////////////////////////////////////////////////////
 // Destructor: ~cQWidgetCreated
 //
 //     Author: $author$           
 //       Date: 8/5/2010
 ///////////////////////////////////////////////////////////////////////
 virtual ~cQWidgetCreated()
 {
     eError error;
     if ((error = Destroyed()))
         throw(error);
 }
예제 #24
0
static mrb_value
bitmap_destroyed(mrb_state *mrb, mrb_value self)
{
  return Destroyed(self);
}
예제 #25
0
 Mesh::~Mesh(){
     meshDestroyed.Notify(Destroyed(this, InstanceID()));
 }        
예제 #26
0
/*!
	This function determines whether the projectile should
	pass through the outter shell of a building and damage
	the occupants instead.

	If so, it proceeds to damage the occupants, and then
	returns true. If the projectile did not pass through,
	and the building has to be damaged according to
	normal rules. the function returns false.

	\return true if the bullet passed through and the damage case was handled, otherwise false.

	\author Renegade
	\date 02.12.09+

*/
bool BulletExt::ExtData::DamageOccupants() {
	auto const pThis = this->OwnerObject();

	auto const pBuilding = abstract_cast<BuildingClass*>(pThis->Target);

	auto const Logging = false;

	// if that pointer is null, something went wrong
	if(!pBuilding) {
		return false;
	}

	auto const pTypeExt = BulletTypeExt::ExtMap.Find(pThis->Type);
	auto const pBldTypeExt = BuildingTypeExt::ExtMap.Find(pBuilding->Type);

	auto const occupants = pBuilding->Occupants.Count;
	auto const passThrough = pBldTypeExt->UCPassThrough.Get();

/*	Debug::Log(
		Logging, "Bullet %s is about to damage occupants of %s: occupants "
		"#%d, UC.PT = %lf\n", pThis->Type->ID, pBuilding->Type->ID,
		occupants, passThrough); */

	// only work when UCPassThrough is set, 
	// as per community vote in thread #1392
	if(!occupants || !passThrough) {
		return false;
	}

	auto const subjectToTrenches = pTypeExt->SubjectToTrenches.Get();
	Debug::Log(Logging, "SubjToTrenches = %d\n", subjectToTrenches);

	// being SubjectToTrenches means "we're getting stopped by trenches".
	auto& Random = ScenarioClass::Instance->Random;
	if(subjectToTrenches && Random.RandomDouble() >= passThrough) {
		return false;
	}

	// which Occupant is getting it?
	auto const idxPoorBastard = Random.RandomRanged(0, occupants - 1);
	auto const pPoorBastard = pBuilding->Occupants[idxPoorBastard];

	Debug::Log(Logging, "Poor Bastard #%d\n", idxPoorBastard);

	auto const fatalRate = pBldTypeExt->UCFatalRate.Get();
	if(fatalRate > 0.0 && Random.RandomDouble() < fatalRate) {
		Debug::Log(Logging, "Fatal hit!\n");
		// fatal hit
		pPoorBastard->Destroyed(pThis->Owner);
		pPoorBastard->UnInit();
		// don't separate these two lines - poor guy's already ~dtor'd,
		// but his pointer is still dangling from the vector
		pBuilding->Occupants.RemoveItem(idxPoorBastard);
		pBuilding->UpdateThreatInCell(pBuilding->GetCell());
	} else {
		// just a flesh wound
		auto const multiplier = pBldTypeExt->UCDamageMultiplier.Get();
		Debug::Log(Logging, "Flesh wound - health(%d) * UCDmgMult(%lf)\n",
			pThis->Health, multiplier);
		// Bullet->Health is the damage it delivers (go Westwood)
		auto adjustedDamage = static_cast<int>(
			std::ceil(pThis->Health * multiplier));
		Debug::Log(Logging, "Adjusted damage = %d\n", adjustedDamage);
		auto const result = pPoorBastard->ReceiveDamage(&adjustedDamage, 0,
			pThis->WH, pThis->Owner, false, true, pThis->GetOwningHouse());
		Debug::Log(Logging, "Received damage, %d\n", result);
	}

	// fix up the firing index, otherwise building stops to fire
	if(pBuilding->FiringOccupantIndex >= pBuilding->GetOccupantCount()) {
		pBuilding->FiringOccupantIndex = 0;
	}

	// if the last occupant was killed and this building was raided,
	// it needs to be returned to its owner. (Bug #700)
	auto const pBuildingExt = BuildingExt::ExtMap.Find(pBuilding);
	pBuildingExt->evalRaidStatus();

	return true;
}
예제 #27
0
파일: mech.c3.misc.c 프로젝트: chazu/btmux
MECH *getOtherMechInNetwork(MECH * mech, int wIdx, int tCheckECM,
							int tCheckStarted, int tCheckUncon, int tIsC3)
{
	MECH *tempMech;
	dbref refOtherMech;
	int networkSize;

	networkSize =
		(tIsC3 ? MechC3NetworkSize(mech) : MechC3iNetworkSize(mech));

	if((wIdx >= networkSize) || (wIdx < 0))
		return NULL;

	refOtherMech =
		(tIsC3 ? MechC3NetworkElem(mech, wIdx) : MechC3iNetworkElem(mech,
																	wIdx));

	if(refOtherMech > 0) {
		tempMech = getMech(refOtherMech);

		if(!tempMech)
			return NULL;

		if(MechTeam(tempMech) != MechTeam(mech))
			return NULL;

		if(tempMech->mapindex != mech->mapindex)
			return NULL;

		if(Destroyed(tempMech))
			return NULL;

		if(tIsC3) {
			if(!HasC3(tempMech))	/* Sanity check */
				return NULL;

			if(C3Destroyed(tempMech))
				return NULL;
		} else {
			if(!HasC3i(tempMech))	/* Sanity check */
				return NULL;

			if(C3iDestroyed(tempMech))
				return NULL;
		}

		if(tCheckECM)
			if(AnyECMDisturbed(tempMech))
				return NULL;

		if(tCheckStarted)
			if(!Started(tempMech))
				return NULL;

		if(tCheckUncon)
			if(Uncon(tempMech))
				return NULL;

		return tempMech;
	}

	return NULL;
}
예제 #28
0
static mrb_value
config_destroyed(mrb_state *mrb, mrb_value self)
{
  return Destroyed(self);
}
예제 #29
0
void mech_c3i_join_leave(dbref player, void *data, char *buffer)
{
    MECH *mech = (MECH *) data, *target;
    MAP *objMap;
    char *args[2];
    dbref refTarget;
    int LOS = 1;
    float range = 0.0;

    cch(MECH_USUALO);

    DOCHECK(mech_parseattributes(buffer, args, 2) != 1,
	"Invalid number of arguments to function!");

    DOCHECK(!HasC3i(mech), "This unit is not equipped with C3i!");
    DOCHECK(C3iDestroyed(mech), "Your C3i system is destroyed!");
    DOCHECK(AnyECMDisturbed(mech),
	"Your C3i system is not currently operational!");

    validateC3iNetwork(mech);

    /* Clear our C3i Network */
    if (!strcmp(args[0], "-")) {
	if (MechC3iNetworkSize(mech) <= 0) {
	    mech_notify(mech, MECHALL,
		"You are not connected to a C3i network!");

	    return;
	}

	clearC3iNetwork(mech, 1);

	mech_notify(mech, MECHALL, "You disconnect from the C3i network.");

	return;
    }

    /* Well, if we're here then we wanna connect to a network */
    /* Let's check to see if we're already in one... can't be in two at the same time */
    DOCHECK(MechC3iNetworkSize(mech) > 0,
	"You are already in a C3i network!");

    objMap = getMap(mech->mapindex);

    /* Find who we're trying to connect to */
    refTarget = FindTargetDBREFFromMapNumber(mech, args[0]);
    target = getMech(refTarget);

    if (target) {
	LOS =
	    InLineOfSight(mech, target, MechX(target), MechY(target),
	    range);
    } else
	refTarget = 0;

    DOCHECK((refTarget < 1) ||
	!LOS, "That is not a valid targetID. Try again.");
    DOCHECK(MechTeam(mech) != MechTeam(target),
	"You can't use the C3i network of unfriendly units!");
    DOCHECK(mech == target, "You can't connect to yourself!");
    DOCHECK(Destroyed(target), "That unit is destroyed!");
    DOCHECK(!Started(target), "That unit is not started!");
    DOCHECK(!HasC3i(target),
	"That unit does not appear to be equipped with C3i!");

    /* validate the network of our target */
    validateC3iNetwork(target);
    DOCHECK(MechC3iNetworkSize(target) >= C3I_NETWORK_SIZE,
	"That unit's C3i network is operating at maximum capacity!");

    /* Connect us up */
    mech_notify(mech, MECHALL, tprintf("You connect to %s's C3i network.",
	    GetMechToMechID(mech, target)));

    addMechToC3iNetwork(target, mech);
}