Beispiel #1
0
void 
xDistributedPoint3F::updateFromServer(xNStream *stream)
{


	if (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)
	{
		TNL::Point3f p;
		stream->readPointCompressed(&p,1.0f);
		Point3F realPos(p.x,p.y,p.z);

		TNL::Point3f v;
		stream->readPointCompressed(&v,1.0f);
		Point3F velocity(v.x,v.y,v.z);

		mLastServerValue = realPos;
		mLastServerDifference = velocity;
	}

	if (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)
	{
		TNL::Point3f p;
		stream->readPointCompressed(&p,1.0f);
		Point3F realPos(p.x,p.y,p.z);
		mLastServerValue = realPos;
	}

	setValueState(E_DV_UPDATED);


	//xLogger::xLog(ELOGINFO,XL_START,"\n vel: %f,%f,%f",velocity.x,velocity.y,velocity.z );
}
Beispiel #2
0
void TextPreview::mouseMoveEvent(QMouseEvent *event)
{
	if(readOnly || (!(event->buttons() & Qt::LeftButton) && !acceptMove))
		return;

	FF8Window ff8Window = getWindow();

	if(ff8Window.type==NOWIN)	return;

	int x = ff8Window.x + event->x() - moveStartPosition.x();
	int y = ff8Window.y + event->y() - moveStartPosition.y();

	if(x<0)	x = 0;
	if(y<0)	y = 0;

	ff8Window.x = x;
	ff8Window.y = y;
	QPoint real = realPos(ff8Window);
	ff8Window.x = real.x();
	ff8Window.y = real.y();

	emit positionChanged(real);

	moveStartPosition = event->pos();

	ff8Windows.replace(currentWin, ff8Window);

	update();
}
Beispiel #3
0
IS::Map::realPos const IS::Map::mapToOgre(unitPos const &pos)
{
	unitPos mid(_config->getDimension().first / 2 + 1, _config->getDimension().second / 2);
	unitPos target(pos - mid);

	return (realPos(_config->getConverter()(target.first) - _config->getOffset().first,
		_config->getConverter()(target.second) - _config->getOffset().second));
}
Beispiel #4
0
bool AIRobot::isCloseEnough()
{
	mWorldTarget = GridToWorld(mGridTarget);
	Vector3 realPos(mNode->GetLocalTranslation());
	float delX = (realPos.x - mWorldTarget.x);
	float delZ = (realPos.z - mWorldTarget.y);
	return ((delX*delX + delZ*delZ) <= mDistMargin);
}
Beispiel #5
0
void IS::Map::putTile(unitPos const &upos, TileType type)
{
	realPos rpos;
	std::shared_ptr<Tile> tile;

	tile = _config->getTile(type);
	rpos = _config->getOffset() + realPos(_config->getConverter()(upos.first - _config->getDimension().first / 2),
		_config->getConverter()(upos.second - _config->getDimension().second / 2));
	tile->_new(upos, rpos);
	_tiles[upos] = tile->clone();
}
Beispiel #6
0
void Quad::destroy() {
    if(currentGameMap->tileExists(location) && isVisible()) {
        Coord realPos(lround(realX), lround(realY));
        currentGame->getExplosionList().push_back(new Explosion(Explosion_SmallUnit, realPos, owner->getHouseID()));

        if(isVisible(getOwner()->getTeam()))
            soundPlayer->playSoundAt(Sound_ExplosionSmall,location);
    }

    GroundUnit::destroy();
}
void SonicTankClass::destroy() {
    if(currentGameMap->cellExists(location) && isVisible()) {
        Coord realPos((short)realX, (short)realY);
        currentGame->getExplosionList().push_back(new Explosion(Explosion_SmallUnit, realPos, owner->getHouseID()));

        if(isVisible(getOwner()->getTeam()))
            soundPlayer->playSoundAt(Sound_ExplosionSmall,location);
    }

    TrackedUnit::destroy();
}
void SiegeTankClass::destroy() {
    if(currentGameMap->cellExists(location) && isVisible()) {
        Coord realPos((short)realX, (short)realY);
        Uint32 explosionID = currentGame->RandomGen.getRandOf(2,Explosion_Medium1, Explosion_Medium2);
        currentGame->getExplosionList().push_back(new Explosion(explosionID, realPos, owner->getHouseID()));

        if(isVisible(getOwner()->getTeam()))
            soundPlayer->playSoundAt(Sound_ExplosionLarge,location);
    }

    TankBaseClass::destroy();
}
void SiegeTank::destroy() {
    if(currentGameMap->tileExists(location) && isVisible()) {
        Coord realPos(lround(realX), lround(realY));
        Uint32 explosionID = currentGame->randomGen.getRandOf(2,Explosion_Medium1, Explosion_Medium2);
        currentGame->getExplosionList().push_back(new Explosion(explosionID, realPos, owner->getHouseID()));

        if(isVisible(getOwner()->getTeam())) {
            screenborder->shakeScreen(18);
            soundPlayer->playSoundAt(Sound_ExplosionLarge,location);
        }
    }

    TankBase::destroy();
}
Beispiel #10
0
/*
*******************************************************************
* Function: 
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
void xDistributedPoint3F::unpack(xNStream *bstream,float sendersOneWayTime)
{
	if (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)
	{
		sendersOneWayTime *= 0.001f;

		TNL::Point3f p;
		bstream->readPointCompressed(&p,1.0f);
		Point3F realPos(p.x,p.y,p.z);


		TNL::Point3f v;
		bstream->readPointCompressed(&v,1.0f);
		Point3F velocity(v.x,v.y,v.z);

		Point3F predictedPos  = realPos + velocity * sendersOneWayTime;
		
		
		setOwnersOneWayTime(sendersOneWayTime);

		mLastValue = mCurrentValue;
		mCurrentValue = predictedPos;
		mDifference= mCurrentValue - mLastValue;
	}

	if (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)
	{

		TNL::Point3f p;
		bstream->readPointCompressed(&p,1.0f);
		Point3F realPos(p.x,p.y,p.z);

		mLastValue = realPos;
		mLastServerValue = realPos;
		mCurrentValue = realPos;
	}
}
Beispiel #11
0
void TextPreview::mousePressEvent(QMouseEvent *event)
{
	if(!readOnly && event->button() == Qt::LeftButton) {
		FF8Window ff8Window = getWindow();
		if(ff8Window.type!=NOWIN) {
			QPoint real = realPos(ff8Window);

			acceptMove = event->x() >= real.x() && event->x() < real.x()+maxW
						 && event->y() >= real.y() && event->y() < real.y()+maxH;

			if(acceptMove) {
				moveStartPosition = event->pos();
				setCursor(QCursor(Qt::ClosedHandCursor));
			}
		}
		else
			acceptMove = false;
	}
}
void DevastatorClass::destroy()
{
    if(currentGameMap->cellExists(location) && isVisible()) {
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                Coord realPos((short)realX + (i - 1)*BLOCKSIZE, (short)realY + (j - 1)*BLOCKSIZE);

                currentGameMap->damage(objectID, owner, realPos, itemID, 150, 16, false);

                Uint32 explosionID = currentGame->RandomGen.getRandOf(2,Explosion_Large1, Explosion_Large2);
                currentGame->getExplosionList().push_back(new Explosion(explosionID, realPos, owner->getHouseID()));
            }
        }

        if(isVisible(getOwner()->getTeam()))
            soundPlayer->playSoundAt(Sound_ExplosionLarge,location);
    }

    TrackedUnit::destroy();
}
Beispiel #13
0
void TextPreview::drawTextArea(QPainter *painter)
{
	useTimer = false;

	if(ff8Text.isEmpty())	return;

	bool jp = font->tableCount() == 4;
	FF8Window ff8Window = getWindow();

	/* Window Background */

	if(ff8Window.type!=NOWIN) {
		painter->translate(realPos(ff8Window));
	}

	painter->setBrush(QPixmap(":/images/menu-fond.png"));

	/* Frame */
	QPen pen(QColor(41,41,41));
	pen.setWidth(1);
	pen.setJoinStyle(Qt::MiterJoin);
	painter->setPen(pen);
	painter->drawRect(0, 0, maxW, maxH);

	painter->setPen(QColor(132,132,132));
	painter->drawLine(2, 1, maxW-2, 1);
	painter->drawLine(1, 2, 1, maxH-2);

	painter->setPen(QColor(58,58,58));
	painter->drawLine(2, maxH-1, maxW-1, maxH-1);
	painter->drawLine(maxW-1, 2, maxW-1, maxH-2);

	painter->setPen(QColor(99,99,99));
	painter->drawPoint(1, 1);

	painter->setPen(QColor(82,82,82));
	painter->drawPoint(maxW-1, 1);
	painter->drawPoint(1, maxH-1);

	int ask_first=-1, ask_last=-1;

	if(ff8Window.type==0x6f) {
		ask_first = ff8Window.ask_first;
		ask_last = ff8Window.ask_last;
		if(ask_last >= ask_first)
			painter->drawPixmap(10, 11+16*ask_first, QPixmap(":/images/cursor.png"));
	}

	/* Text */

	fontColor = TdwFile::White;

	int charId, line=0, x = (ask_first==0 && ask_last>=0 ? 40 : 8), y = 8;
	int start = pagesPos.value(currentPage, 0), size = ff8Text.size();

	for(int i=start ; i<size ; ++i)
	{
		charId = (quint8)ff8Text.at(i);

		if(charId>=32)
		{
			if(jp) {
				letter(&x, &y, charId-32, painter);// 210-32
			} else {
				if(charId<227) {
					letter(&x, &y, charId-32, painter);
				} else if(charId>=232) {
					letter(&x, &y, optimisedDuo[charId-232][0], painter);
					letter(&x, &y, optimisedDuo[charId-232][1], painter);
				}
			}
		}
		else if(charId<=1)//NewPage
			break;
		else if(charId==2)//\n
		{
			++line;
			x = (ask_first<=line && ask_last>=line ? 40 : 8);
			y += 16;
		}
		else if(charId<32)
		{
			++i;
			switch(charId)
			{
			case 0x03: // Character names
				charId = (quint8)ff8Text.at(i);

				if(charId>=0x30 && charId<=0x3a)
					word(&x, &y, names.at(charId-0x30), painter, 5);
				else if(charId==0x40)
					word(&x, &y, names.at(11), painter, 5);
				else if(charId==0x50)
					word(&x, &y, names.at(12), painter, 5);
				else if(charId==0x60)
					word(&x, &y, names.at(13), painter, 5);
				break;
			case 0x04:// Var
				charId = (quint8)ff8Text.at(i);

				if((charId>=0x20 && charId<=0x27) || (charId>=0x30 && charId<=0x37))
					word(&x, &y, FF8Text::toFF8("0", false), painter);
				else if(charId>=0x40 && charId<=0x47)
					word(&x, &y, FF8Text::toFF8("00000000", false), painter);
				break;
			case 0x05: // Icons
				charId = (quint8)ff8Text.at(i)-0x20;

				if(charId>=0 && charId<96)
				{
					painter->drawImage(x, y, getIconImage(charId));
					x += iconWidth[charId] + iconPadding[charId];
				}
				break;
			case 0x06: // Colors
				charId = (quint8)ff8Text.at(i);

				if(charId>=0x20 && charId<=0x27)// Colors
					fontColor = (TdwFile::Color)(charId-0x20);
				else if(charId>=0x28 && charId<=0x2f)// BlinkColors
				{
					useTimer = true;
					fontColor = (TdwFile::Color)(charId-0x20);
				}
				break;
			case 0x0e: // Locations
				charId = (quint8)ff8Text.at(i);
				if(charId>=0x20 && charId<=0x27)
					word(&x, &y, locations.at(charId-0x20), painter, 5);
				break;
			case 0x19: // Jap 1
				if(jp) {
					letter(&x, &y, (quint8)ff8Text.at(i)-0x20, painter, 1);
				}
				break;
			case 0x1a: // Jap 2
				if(jp) {
					letter(&x, &y, (quint8)ff8Text.at(i)-0x20, painter, 2);
				}
				break;
			case 0x1b: // Jap 3
				if(jp) {
					letter(&x, &y, (quint8)ff8Text.at(i)-0x20, painter, 3);
				}
				break;
			case 0x1c: // Jap 4
				if(jp) {
					letter(&x, &y, (quint8)ff8Text.at(i)-0x20, painter, 4);
				}
				break;
			}
		}
	}
}