Beispiel #1
0
void SVGTRefTargetEventListener::handleEvent(ScriptExecutionContext*, Event* event)
{
    ASSERT(isAttached());

    if (event->type() == eventNames().DOMSubtreeModifiedEvent && &m_trefElement != event->target())
        m_trefElement.updateReferencedText(m_target.get());
    else if (event->type() == eventNames().DOMNodeRemovedFromDocumentEvent)
        m_trefElement.detachTarget();
}
Beispiel #2
0
void SVGTRefTargetEventListener::detach()
{
    if (!isAttached())
        return;

    m_target->removeEventListener(eventNames().DOMSubtreeModifiedEvent, this, false);
    m_target->removeEventListener(eventNames().DOMNodeRemovedFromDocumentEvent, this, false);
    m_target = nullptr;
}
bool PlayerSAO::checkMovementCheat()
{
	if (isAttached() || m_is_singleplayer ||
			g_settings->getBool("disable_anticheat")) {
		m_last_good_position = m_base_position;
		return false;
	}

	bool cheated = false;
	/*
		Check player movements

		NOTE: Actually the server should handle player physics like the
		client does and compare player's position to what is calculated
		on our side. This is required when eg. players fly due to an
		explosion. Altough a node-based alternative might be possible
		too, and much more lightweight.
	*/

	float player_max_speed = 0;

	if (m_privs.count("fast") != 0) {
		// Fast speed
		player_max_speed = m_player->movement_speed_fast * m_physics_override_speed;
	} else {
		// Normal speed
		player_max_speed = m_player->movement_speed_walk * m_physics_override_speed;
	}
	// Tolerance. The lag pool does this a bit.
	//player_max_speed *= 2.5;

	v3f diff = (m_base_position - m_last_good_position);
	float d_vert = diff.Y;
	diff.Y = 0;
	float d_horiz = diff.getLength();
	float required_time = d_horiz / player_max_speed;

	if (d_vert > 0 && d_vert / player_max_speed > required_time)
		required_time = d_vert / player_max_speed; // Moving upwards

	if (m_move_pool.grab(required_time)) {
		m_last_good_position = m_base_position;
	} else {
		const float LAG_POOL_MIN = 5.0;
		float lag_pool_max = m_env->getMaxLagEstimate() * 2.0;
		lag_pool_max = MYMAX(lag_pool_max, LAG_POOL_MIN);
		if (m_time_from_last_teleport > lag_pool_max) {
			actionstream << "Player " << m_player->getName()
					<< " moved too fast; resetting position"
					<< std::endl;
			cheated = true;
		}
		setBasePosition(m_last_good_position);
	}
	return cheated;
}
Beispiel #4
0
void truncate(char*& argv) {
    // General level 3 depth - ";)
    if (hasEndParenthesis(argv) && isAttached(argv) && isQuoteEnd(argv)) {
        argv[strlen(argv) - 3] = ';';
        argv[strlen(argv) - 2] = ')';
    }
    // General level 2 depth - ") or ;) or ";
    else if (argv[strlen(argv) - 2] == ';' && hasEndParenthesis(argv)) {
        argv[strlen(argv) - 2] = ')';
    }
    else if (argv[strlen(argv) - 2] == '"' && hasEndParenthesis(argv)) {
        argv[strlen(argv) - 2] = ')';
    }
    else if (argv[strlen(argv) - 2] == '"' && isAttached(argv)) {
        argv[strlen(argv) - 2] = ';';
    }
    argv[strlen(argv) - 1] = '\0';
    return;
}
bool GuiElement::detach(AttachSide side)
{
	if(isAttached(side))
	{
		getAttached(side)->detach(this);
		return true;
	}
	else
		return false;
}
Beispiel #6
0
void PlayerSAO::moveTo(v3f pos, bool continuous)
{
	if(isAttached())
		return;

	setBasePosition(pos);
	// Movement caused by this command is always valid
	m_last_good_position = pos;
	((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
Beispiel #7
0
NSignal1<Param1>::~NSignal1(void) {
	for(typename SlotHandlersMap::iterator it = m_slots.begin(); 
		   it != m_slots.end(); 
		   it++)
	{
		if(isAttached(it.key())) {
			it.value()->disconnect();
		}
	}
}
Beispiel #8
0
void PlayerSAO::moveTo(v3f pos, bool continuous)
{
	if(isAttached())
		return;
	m_player->setPosition(pos);
	// Movement caused by this command is always valid
	m_last_good_position = pos;
	// Force position change on client
	m_moved = true;
}
Beispiel #9
0
//--------------------------------------------------------------------------------
bool CAutoLayoutContainerView::changeViewZOrder (CView* view, uint32_t newIndex)
{
	if (CViewContainer::changeViewZOrder (view, newIndex))
	{
		if (isAttached ())
			layoutViews ();
		return true;
	}
	return false;
}
void PropertyEditorView::setupPanes()
{
    if (isAttached()) {
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
        setupPane("QtQuick.Item");
        resetView();
        m_setupCompleted = true;
        QApplication::restoreOverrideCursor();
    }
}
Beispiel #11
0
void LuaEntitySAO::rightClick(ServerActiveObject *clicker)
{
	if(!m_registered)
		return;
	// It's best that attachments cannot be clicked
	if(isAttached())
		return;
	lua_State *L = m_env->getLua();
	scriptapi_luaentity_rightclick(L, m_id, clicker);
}
Beispiel #12
0
void AiTankController::moveTo(const Point2f &pos, const Point2f &nextPos)
{
    if (!isAttached())
        return;

    turnTo(pos);
    bCheckMoveTo = true;
    moveToPos = pos;
    nextMoveToPos = nextPos;
}
//-----------------------------------------------------------------------
void SphereColliderExtern::_preProcessParticles(ParticleTechnique* particleTechnique, Real timeElapsed)
{
    if (isAttached())
    {
        // Use the position of the parent node in this case.
        position = getParentNode()->_getDerivedPosition();
        mDerivedPosition = position;
        mSphere.setCenter(mDerivedPosition);
    }
}
Beispiel #14
0
//--------------------------------------------------------------------------------
bool CAutoLayoutContainerView::removeView (CView* pView, bool withForget)
{
	if (CViewContainer::removeView (pView, withForget))
	{
		if (isAttached ())
			layoutViews ();
		return true;
	}
	return false;
}
Beispiel #15
0
//--------------------------------------------------------------------------------
bool CAutoLayoutContainerView::addView (CView* pView, CView* pBefore)
{
	if (CViewContainer::addView (pView, pBefore))
	{
		if (isAttached ())
			layoutViews ();
		return true;
	}
	return false;
}
Beispiel #16
0
//--------------------------------------------------------------------------------
bool CAutoLayoutContainerView::addView (CView* pView, const CRect& mouseableArea, bool mouseEnabled)
{
	if (CViewContainer::addView (pView, mouseableArea, mouseEnabled))
	{
		if (isAttached ())
			layoutViews ();
		return true;
	}
	return false;
}
Beispiel #17
0
void SVGTRefTargetEventListener::attach(PassRefPtr<Element> target)
{
    ASSERT(!isAttached());
    ASSERT(target.get());
    ASSERT(target->inDocument());

    target->addEventListener(eventNames().DOMSubtreeModifiedEvent, this, false);
    target->addEventListener(eventNames().DOMNodeRemovedFromDocumentEvent, this, false);
    m_target = target;
}
Beispiel #18
0
bool PlayerSAO::checkMovementCheat()
{
	bool cheated = false;
	if(isAttached() || m_is_singleplayer ||
			g_settings->getBool("disable_anticheat"))
	{
		m_last_good_position = m_player->getPosition();
	}
	else
	{
		/*
			Check player movements

			NOTE: Actually the server should handle player physics like the
			client does and compare player's position to what is calculated
			on our side. This is required when eg. players fly due to an
			explosion. Altough a node-based alternative might be possible
			too, and much more lightweight.
		*/

		float player_max_speed = 0;
		float player_max_speed_up = 0;
		if(m_privs.count("fast") != 0){
			// Fast speed
			player_max_speed = m_player->movement_speed_fast;
			player_max_speed_up = m_player->movement_speed_fast;
		} else {
			// Normal speed
			player_max_speed = m_player->movement_speed_walk;
			player_max_speed_up = m_player->movement_speed_walk;
		}
		// Tolerance. With the lag pool we shouldn't need it.
		//player_max_speed *= 2.5;
		//player_max_speed_up *= 2.5;

		v3f diff = (m_player->getPosition() - m_last_good_position);
		float d_vert = diff.Y;
		diff.Y = 0;
		float d_horiz = diff.getLength();
		float required_time = d_horiz/player_max_speed;
		if(d_vert > 0 && d_vert/player_max_speed > required_time)
			required_time = d_vert/player_max_speed;
		if(m_move_pool.grab(required_time)){
			m_last_good_position = m_player->getPosition();
		} else {
			actionstream<<"Player "<<m_player->getName()
					<<" moved too fast; resetting position"
					<<std::endl;
			m_player->setPosition(m_last_good_position);
			m_moved = true;
			cheated = true;
		}
	}
	return cheated;
}
/*!
  Sets a new \a key for this shared memory object.  If \a key and the
  current key are the same, the function returns without doing
  anything. If the shared memory object is attached to an underlying
  shared memory segment, it will \l {detach()} {detach} from it before
  setting the new key. This function does not do an attach().

  \sa key() isAttached()
 */
void QSharedMemory::setKey(const QString &key)
{
    Q_D(QSharedMemory);
    if (key == d->key)
        return;

    if (isAttached())
        detach();
    d->cleanHandle();
    d->key = key;
}
	//-----------------------------------------------------------------------
	void BoxColliderExtern::_preProcessParticles(ParticleTechnique* particleTechnique, Real timeElapsed)
	{
		if (isAttached())
		{
			// Use the position of the parent node in this case.
			position = getParentNode()->_getDerivedPosition();
			mDerivedPosition = position;
			populateAlignedBox(mBox, mDerivedPosition, mWidth, mHeight, mDepth);
			_calculateBounds();
		}
	}
Beispiel #21
0
void AiTankController::goTo(const Point2f &pos) // findPath and go
{
    if (!isAttached())
        return;

    Operate moveTo(Operate::CI_MoveTo);
    if (findPathTo(pos, moveTo.wayPoints))
    {
        operates.push(moveTo);
    }
}
Vector FloorLocator::getSurfaceNormal_l ( void ) const
{
	if(isAttached())
	{
		return getFloorTri().getNormal();
	}
	else
	{
		return Vector::unitY;
	}
}
Beispiel #23
0
void Object::attach( const UUID& id, const uint32_t instanceID )
{
    LBASSERT( !isAttached() );
    LBASSERT( impl_->localNode );
    LBASSERT( instanceID <= EQ_INSTANCE_MAX );

    impl_->id         = id;
    impl_->instanceID = instanceID;
    LBLOG( LOG_OBJECTS )
        << impl_->id << '.' << impl_->instanceID << ": " << lunchbox::className( this )
        << (isMaster() ? " master" : " slave") << std::endl;
}
Beispiel #24
0
/*!
  Sets the platform independent \a key for this shared memory object. If \a key
  is the same as the current key, the function returns without doing anything.

  You can call key() to retrieve the platform independent key. Internally,
  QSharedMemory converts this key into a platform specific key. If you instead
  call nativeKey(), you will get the platform specific, converted key.

  If the shared memory object is attached to an underlying shared memory
  segment, it will \l {detach()} {detach} from it before setting the new key.
  This function does not do an attach().

  \sa key() nativeKey() isAttached()
*/
void QSharedMemory::setKey(const QString &key)
{
    Q_D(QSharedMemory);
    if (key == d->key && d->makePlatformSafeKey(key) == d->nativeKey)
        return;

    if (isAttached())
        detach();
    d->cleanHandle();
    d->key = key;
    d->nativeKey = d->makePlatformSafeKey(key);
}
void PlayerSAO::moveTo(v3f pos, bool continuous)
{
	if(isAttached())
		return;

	setBasePosition(pos);
	// Movement caused by this command is always valid
	m_last_good_position = pos;
	m_move_pool.empty();
	m_time_from_last_teleport = 0.0;
	m_env->getGameDef()->SendMovePlayer(m_peer_id);
}
Beispiel #26
0
void Object::attach( const base::UUID& id, const uint32_t instanceID )
{
    EQASSERT( !isAttached() );
    EQASSERT( _localNode );
    EQASSERT( instanceID <= EQ_INSTANCE_MAX );

    _id         = id;
    _instanceID = instanceID;
    EQLOG( LOG_OBJECTS )
        << _id << '.' << _instanceID << ": " << base::className( this )
        << (isMaster() ? " master" : " slave") << std::endl;
}
Beispiel #27
0
//-----------------------------------------------------------------------------
bool UIViewSwitchContainer::removed (CView* parent)
{
	if (isAttached ())
	{
		bool result = CViewContainer::removed (parent);
		if (result && controller)
			controller->switchContainerRemoved ();
		CViewContainer::removeAll ();
		return result;
	}
	return false;
}
Beispiel #28
0
int LuaEntitySAO::punch(v3f dir,
		const ToolCapabilities *toolcap,
		ServerActiveObject *puncher,
		float time_from_last_punch)
{
	if (!m_registered){
		// Delete unknown LuaEntities when punched
		m_removed = true;
		return 0;
	}

	// It's best that attachments cannot be punched
	if (isAttached())
		return 0;

	ItemStack *punchitem = NULL;
	ItemStack punchitem_static;
	if (puncher) {
		punchitem_static = puncher->getWieldedItem();
		punchitem = &punchitem_static;
	}

	PunchDamageResult result = getPunchDamage(
			m_armor_groups,
			toolcap,
			punchitem,
			time_from_last_punch);

	if (result.did_punch) {
		setHP(getHP() - result.damage);

		if (result.damage > 0) {
			std::string punchername = puncher ? puncher->getDescription() : "nil";

			actionstream << getDescription() << " punched by "
					<< punchername << ", damage " << result.damage
					<< " hp, health now " << getHP() << " hp" << std::endl;
		}

		std::string str = gob_cmd_punched(result.damage, getHP());
		// create message and add to list
		ActiveObjectMessage aom(getId(), true, str);
		m_messages_out.push(aom);
	}

	if (getHP() == 0)
		m_removed = true;

	m_env->getScriptIface()->luaentity_Punch(m_id, puncher,
			time_from_last_punch, toolcap, dir);

	return result.wear;
}
Beispiel #29
0
/*!
  \since 4.8

  Sets the native, platform specific, \a key for this shared memory object. If
  \a key is the same as the current native key, the function returns without
  doing anything. If all you want is to assign a key to a segment, you should
  call setKey() instead.

  You can call nativeKey() to retrieve the native key. If a native key has been
  assigned, calling key() will return a null string.

  If the shared memory object is attached to an underlying shared memory
  segment, it will \l {detach()} {detach} from it before setting the new key.
  This function does not do an attach().

  The application will not be portable if you set a native key.

  \sa nativeKey() key() isAttached()
*/
void QSharedMemory::setNativeKey(const QString &key)
{
    Q_D(QSharedMemory);
    if (key == d->nativeKey && d->key.isNull())
        return;

    if (isAttached())
        detach();
    d->cleanHandle();
    d->key.clear();
    d->nativeKey = key;
}
Beispiel #30
0
void AiTankController::stepMoveTo()
{
    if (!isAttached())
    {
        bCheckMoveTo = false;
        return;
    }
    Point2f posTank;
    float orientionTank;
    Entity &e = entity->getEntity();
    if (e.getStatus(Entity::ESI_Position, &posTank) &&
        e.getStatus(Entity::ESI_Orientation, &orientionTank))
    {
    //#ifndef NDEBUG
        iRenderQueue::getSingleton().render(moveToPos, posTank, ARGB(255, 0, 0, 0));
//#endif
        Point2f dir = moveToPos - posTank;
        float len = dir.Length();
        float len2 = (nextMoveToPos - posTank).Length();
        if (len < 10 || len > len2)
        {
            bCheckMoveTo = false;
            bForward = false;
            sendCommand(Tank::TCI_Forward, (void *)bForward);
            return;
        }
        dir.Normalize();
        if (fabs(dir ^ Point2f(cos(orientionTank), sin(orientionTank))) < 0.3f)
        {
            if (!bForward)
            {
                bForward = true;
                sendCommand(Tank::TCI_Forward, (void *)bForward);
            }
        }
        else
        {
            float lerpValue = (float)rand() / RAND_MAX;
            lerpValue *= lerpValue;
            turnTo(moveToPos);//lerp(moveToPos, nextMoveToPos, lerpValue));
            if (bForward)
            {
                bForward = false;
                sendCommand(Tank::TCI_Forward, (void *)bForward);
            }
        }
    }
    else
    {
        bCheckMoveTo = false;
    }
}