Exemplo n.º 1
0
void GOS_PowerUp::update(const std::string &str)
{
    std::istringstream istr(str);
    char endCheck;
    int type = -1;
    int bonus;
    double degree, posX, posY, speed;
    int objID, playerID, damage, ttl;
    double sprite_w, sprite_h, hb_w, hb_h;
    double tl_x, tl_y;
    double tr_x, tr_y;
    double bl_x, bl_y;
    double br_x, br_y;

    istr >> type;
    switch(ObjectType(type))
    {
    case POWERUP:
        sprite_w = double(POWERUP_SPRITE_WIDTH);
        sprite_h = double(POWERUP_SPRITE_HEIGHT);
        hb_w = double(POWERUP_WIDTH);
        hb_h = double(POWERUP_HEIGHT);

        istr >> objID >> degree >> posX >> posY >> playerID >> speed >> ttl
             >> damage
             >> tl_x >> tl_y
             >> tr_x >> tr_y
             >> bl_x >> bl_y
             >> br_x >> br_y
             >> bonus
             >> endCheck;

        if(!istr.good() || endCheck != POWERUP_STR)
                break;

        hb_.tLeft = Point(tl_x, tl_y);
        hb_.tRight = Point(tr_x, tr_y);
        hb_.bLeft = Point(bl_x, bl_y);
        hb_.bRight = Point(br_x, br_y);

        type_ = ObjectType(type);
        objID_ = objID;
        degree_.setDegree(degree);
        pos_.setX(posX);
        pos_.setY(posY);
        playerID_ = playerID;
        speed_ = speed;
        ttl_ = ttl;
        damage_ = damage;
        spritePt_.setX(pos_.getX()-(sprite_w/2));
        spritePt_.setY(pos_.getY()-(sprite_h/2));
        bonus_ = BONUS(bonus);
        break;
    }
}
Exemplo n.º 2
0
std::string IncapacitationEvent::CombatLogDescription(int viewing_empire_id) const {
    auto object = GetUniverseObject(object_id);
    std::string template_str, object_str;
    int owner_id = object_owner_id;

    if (!object && object_id < 0) {
        template_str = UserString("ENC_COMBAT_FIGHTER_INCAPACITATED_STR");
        object_str = UserString("OBJ_FIGHTER");

    } else if (!object) {
        template_str = UserString("ENC_COMBAT_UNKNOWN_DESTROYED_STR");
        object_str = UserString("ENC_COMBAT_UNKNOWN_OBJECT");

    } else if (object->ObjectType() == OBJ_PLANET) {
        template_str = UserString("ENC_COMBAT_PLANET_INCAPACITATED_STR");
        object_str = PublicNameLink(viewing_empire_id, object_id);

    } else {    // ships or other to-be-determined objects...
        template_str = UserString("ENC_COMBAT_DESTROYED_STR");
        object_str = PublicNameLink(viewing_empire_id, object_id);
    }

    std::string owner_string = " ";
    if (const Empire* owner = GetEmpire(owner_id))
        owner_string += owner->Name() + " ";

    std::string object_link = FighterOrPublicNameLink(viewing_empire_id, object_id, object_owner_id);

    return str(FlexibleFormat(template_str) % owner_string % object_link);
}
void Object::Remove()
{
    Player *p = 0;

    u32 * sector_list = m_ObjectMgr->GetSectorList();

    if (ObjectType() == OT_PLAYER)
    {
        return;
    }

    m_Mutex.Lock();

	while (g_PlayerMgr->GetNextPlayerOnList(p, sector_list))
	{
		if (p)
		{
			if (GetIndex(p->ObjectRangeList()))
			{
				p->RemoveObject(GameID());
				UnSetIndex(p->ObjectRangeList());
			}
			UnSetIndex(p->ResourceSendList());
		}
	}

    m_Mutex.Unlock();

    //now we want to remove the object from the display list
    //SetRemove();
}
Exemplo n.º 4
0
void EditStickyNoteAfterDrop(BumpObject * object) 
{
	// ensure that it is a sticky note
	if (object->isObjectType(ObjectType(BumpActor, FileSystem, StickyNote)))
	{
		StickyNoteActor * actor = (StickyNoteActor *) object;
		actor->launchEditDialog(true);
	}
}
Exemplo n.º 5
0
bool LinkHints::getObjectAtPos(gdouble x, gdouble y, ObjectType *obj) {
	for(iterator h = begin(); h != end(); h++) {
		Gdk::Rectangle r = (*h)->drawRect();
		if(x >= r.get_x() && y >= r.get_y() && x <= r.get_x() + r.get_width() && y <= r.get_y() + r.get_height()) {
			*obj = ObjectType(*h);
			return true;
		}
	}
	return false;
}
Exemplo n.º 6
0
// ---------------------------------------------------------------------------
// CAccPolMixerUnit::ExternalizeL()
// ---------------------------------------------------------------------------
//
void CAccPolMixerUnit::ExternalizeL( RWriteStream& aStream ) const
    {
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolMixerUnit::ExternalizeL() -Enter" );
    //
    //Add object type at the beginning.
    //
    aStream.WriteUint8L( ObjectType() );
    ExternalizeAudioUnitBaseL( aStream );
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolMixerUnit::ExternalizeL - Return" );
    }
char Object::IsNav()
{
    if (ObjectType() == OT_NAV)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
Exemplo n.º 8
0
Parser::Parser(ParsingOption& option)
    : _object(static_cast<Object&>(option)),
      _sharedType(new std::pair<bool, ObjectType>(false, ObjectType())),
      _headParsed(false),
      _parsed(false),
      _tailParsed(false),
      _hasHead(true),
      _hasTail(true)
{

}
Exemplo n.º 9
0
void FileSystemActor::setSizeAnim( Vec3 &startSize, Vec3 &lastSize, uint steps )
{
	sizeAnim.clear();

	// Create a nice Bounce animation
	sizeAnim = bounceGrow(startSize, lastSize, steps);

	// Add to the animation manager
	if (isObjectType(ObjectType(BumpActor, FileSystem, StickyNote)))
		animManager->addAnimation(AnimationEntry(this, (FinishedCallBack) SyncStickyNoteAfterResize, NULL, true));
	else
		animManager->addAnimation(AnimationEntry(this, NULL, NULL, true));
	bool hasGridPileParent = getParent() && getParent()->isObjectType(ObjectType(BumpPile, NULL, Grid));
 	if (hasGridPileParent && isFileSystemType(Image))
	{
 		animManager->finishAnimation(this);

		// We need to add an animation to make sure the updatePileStateAfterAnim is called
		sizeAnim.push_back(lastSize);
		animManager->addAnimation(AnimationEntry(this, (FinishedCallBack) updatePileStateAfterAnim, NULL, true));
	}
}
Exemplo n.º 10
0
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;
        }
    }
}
Exemplo n.º 11
0
void SpeciesManager::UpdatePopulationCounter() {
    // ships of each species and design
    m_species_object_populations.clear();
    for (const auto& entry : Objects().ExistingObjects()) {
        auto obj = entry.second;
        if (obj->ObjectType() != OBJ_PLANET && obj->ObjectType() != OBJ_POP_CENTER)
            continue;

        auto pop_center = std::dynamic_pointer_cast<PopCenter>(obj);
        if (!pop_center)
            continue;

        const std::string& species = pop_center->SpeciesName();
        if (species.empty())
            continue;

        try {
            m_species_object_populations[species][obj->ID()] += obj->CurrentMeterValue(METER_POPULATION);
        } catch (...) {
            continue;
        }
    }
}
Exemplo n.º 12
0
void GOS_Obstacle::update(const std::string &str)
{
    std::istringstream istr(str);
    char endCheck;
    int type = -1;
    int objID, degree, posX, posY;

    istr >> type;
    switch(ObjectType(type))
    {
    case OBSTACLE:
        istr >> objID >> degree >> posX >> posY >> endCheck;

        if(!istr.good() || endCheck != OBSTACLE_STR)
            break;

        type_ = ObjectType(type);
        objID_ = objID;
        degree_.setDegree(double(degree));
        pos_.setX(double(posX));
        pos_.setY(double(posY));
        break;
    }
}
Exemplo n.º 13
0
ObjectType Module::specifyLocally(const ObjectType& parent) const
{
    auto it = _specializers.find(const_cast<ObjectTypeTemplate*>(&parent.typeTemplate()));
    if (it == _specializers.end())
    {
        return ObjectType();
    }

    ObjectType type = it->second.specialize(parent);
    if (!type.isNull())
    {
        type.importParameters(parent);
    }

    return type;
}
Exemplo n.º 14
0
void StaticMap::SendNavigation(Player *player)
{
    //Current Nav info workings (09/01/08). Three types of nav as follows:
    //1. Clickable, on minimap: AppearsInRadar = 1, NavType = 1 or 2 [1 is warp-path nav, 2 is destination only].
    //2. Clickable, not on minimap: AppearsInRadar = 0, NavType = 1 or 2
    //3. Non Clickable, not on minimap: AppearsInRadar = 0, NavType = 0

    if (HasNavInfo() && NavType() > 0 && AppearsInRadar())
    {
        char explored = GetEIndex(player->ExploredNavList()) ? 1 : 0;      
        if (ObjectType() == OT_PLANET) explored = 1;

        player->SendNavigation(GameID(), Signature() + 5000.0f, 
            explored, 
            NavType(), IsHuge());
    }
}
Exemplo n.º 15
0
ObjectType Module::specify(const ObjectType &parent) const
{
    if (!parent.typeTemplate().isVirtual()) {
       return ObjectType();
    }

    ObjectType child = specifyLocally(parent);
    if(child.isNull())
    {
        for(const Module* importedModule : _importedModulesChain)
        {
            child = importedModule->specifyLocally(parent);
            if(!child.isNull())
                break;
        }
    }
    return child;
}
// ---------------------------------------------------------------------------
// CAccPolAudioTopologyObjectCon::ExternalizeL()
// ---------------------------------------------------------------------------
//
EXPORT_C void CAccPolAudioStreamFormatCon::ExternalizeL( RWriteStream& aStream ) const
    {
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioStreamFormatCon::ExternalizeL() - Enter" );
    TInt count( Count() );

    aStream.WriteUint8L( ObjectType() );// Type of object
    aStream.WriteUint8L( count );//Count

    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioStreamFormatCon::ExternalizeL - object type  = %d", ObjectType() );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioStreamFormatCon::ExternalizeL - object count = %d", count );

    for( TInt i = 0; i < count; i++ )
        {
        AtL( i )->ExternalizeL( aStream );
        }

    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioStreamFormatCon::ExternalizeL - Return" );
    }
Exemplo n.º 17
0
ObjectTypes ObjectTypesReader::readObjectTypes(const QString &fileName)
{
    mError.clear();

    ObjectTypes objectTypes;

    QFile file(fileName);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        mError = QCoreApplication::translate(
                    "ObjectTypes", "Could not open file.");
        return objectTypes;
    }

    QXmlStreamReader reader(&file);

    if (!reader.readNextStartElement() || reader.name() != QLatin1String("objecttypes")) {
        mError = QCoreApplication::translate(
                    "ObjectTypes", "File doesn't contain object types.");
        return objectTypes;
    }

    while (reader.readNextStartElement()) {
        if (reader.name() == QLatin1String("objecttype")) {
            const QXmlStreamAttributes atts = reader.attributes();

            const QString name(atts.value(QLatin1String("name")).toString());
            const QColor color(atts.value(QLatin1String("color")).toString());

            objectTypes.append(ObjectType(name, color));
        }
        reader.skipCurrentElement();
    }

    if (reader.hasError()) {
        mError = QCoreApplication::translate("ObjectTypes",
                                             "%3\n\nLine %1, column %2")
                .arg(reader.lineNumber())
                .arg(reader.columnNumber())
                .arg(reader.errorString());
        return objectTypes;
    }

    return objectTypes;
}
Exemplo n.º 18
0
// ---------------------------------------------------------------------------
// CAccPolHdmiLatency::ExternalizeL()
// ---------------------------------------------------------------------------
//
void CAccPolHdmiLatency::ExternalizeL( RWriteStream& aStream ) const
{
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::ExternalizeL() - Enter" );

    //Add object type at the beginning
    aStream.WriteUint8L( ObjectType() );

    //Add data
    aStream.WriteInt32L( iLatencyType.iUid );
    aStream.WriteUint32L( iAudioLatency );
    aStream.WriteUint32L( iVideoLatency );

    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::ExternalizeL - Object Type     = %d", ObjectType() );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::ExternalizeL - LatencyType Uid = %d", iLatencyType.iUid );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::ExternalizeL - Audio Latency   = %d", iAudioLatency );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::ExternalizeL - Video Latency   = %d", iVideoLatency );

    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::ExternalizeL - Return" );
}
Exemplo n.º 19
0
//Send object to all players who can see this object. Currently used only for resource hijacks
void StaticMap::SendToVisibilityList(bool include_player)
{
	Player * p = (0);
    u32 * sector_list = m_ObjectMgr->GetSectorList();
	if (sector_list)
	{
		while (g_PlayerMgr->GetNextPlayerOnList(p, sector_list))
		{
			if (p) 
			{
				switch (ObjectType())
				{
				case OT_PLANET:
					p->SendPlanetPositionalUpdate(GameID(), PosInfo());
					break;

				default:
					p->SendAdvancedPositionalUpdate(GameID(), PosInfo());
					break;
				}
			}
		}
	}
}
Exemplo n.º 20
0
ObjectType Module::getFather(const ObjectType &child) const
{
    //Searching locally
    auto it = _extensions.find(&child.typeTemplate());
    if(it != _extensions.end())
    {
        ObjectType father = (it->second)(child);
        if(!father.isNull())
        {
            return father;
        }
    }

    //Searching in imported modules
    for(const Module* module: reverse(_importedModules))
    {
        ObjectType father = module->getFather(child);
        if(!father.isNull())
        {
            return father;
        }
    }
    return ObjectType();
}
// ---------------------------------------------------------------------------
// CAccPolHdmiAudioFormat::ExternalizeL()
// ---------------------------------------------------------------------------
//
void CAccPolHdmiAudioFormat::ExternalizeL( RWriteStream& aStream ) const
    {
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiAudioFormat::ExternalizeL() - Enter" );

    //Add object type at the beginning
    aStream.WriteUint8L( ObjectType() );

    aStream.WriteInt32L( iAudioFormat.iUid );
    aStream.WriteUint32L( iMaxChannelCount );
    aStream.WriteUint32L( iBitResolution );
    aStream.WriteUint32L( iMaxBitResolution );
    aStream.WriteUint32L( iSamFreq );
    aStream.WriteUint32L( iFormateDependentValue );

    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiAudioFormat::ExternalizeL - Object Type             = %d", ObjectType() );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiAudioFormat::ExternalizeL - AudioFormat Uid         = %d", iAudioFormat.iUid );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiAudioFormat::ExternalizeL - Channel count           = %d", iMaxChannelCount );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiAudioFormat::ExternalizeL - Bit Resolution          = %d", iBitResolution );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiAudioFormat::ExternalizeL - Maximum Bit Resolution  = %d", iMaxBitResolution );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiAudioFormat::ExternalizeL - Sam Freq                = %d", iSamFreq );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiAudioFormat::ExternalizeL - Format Dependen tValue  = %d", iFormateDependentValue );

    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiAudioFormat::ExternalizeL - Return" );
    }
Exemplo n.º 22
0
// ---------------------------------------------------------------------------
// CAccPolHdmiLatency::InternalizeL()
// ---------------------------------------------------------------------------
//
void CAccPolHdmiLatency::InternalizeL( RReadStream& aStream )
{
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::InternalizeL() - Enter" );

    //Read data
    iLatencyType.iUid = aStream.ReadInt32L();
    iAudioLatency = aStream.ReadUint32L();
    iVideoLatency = aStream.ReadUint32L();

    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::InternalizeL - Object Type     = %d", ObjectType() );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::InternalizeL - LatencyType Uid = %d", iLatencyType.iUid );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::InternalizeL - Audio Latency   = %d", iAudioLatency );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::InternalizeL - Video Latency   = %d", iVideoLatency );

    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolHdmiLatency::InternalizeL - Return" );
}
Exemplo n.º 23
0
bool FileSystemManager::deleteFiles(vector<FileSystemActor *> objList, vector<FileSystemActor *> &failedObj, bool confirm, bool skipRecycleBin)
{
	if (objList.empty())
		return true;
	
	FileSystemActor *data;
	SHFILEOPSTRUCT fileOperation = { 0 };
	vector<FileSystemActor *> delList;
	int numVirtualIconsDeleted = 0;

	TCHAR * fromPaths = allocateStringFromPathsArray(objList);
	TCHAR * fromPathsOffset = fromPaths;

	// build the paths of files to delete
	for (int i = 0; i < objList.size(); i++)
	{
		// Check if its a filesystem actor
		if (objList[i]->getObjectType() == ObjectType(BumpActor, FileSystem))
		{
			data = (FileSystemActor *) objList[i];

			// Exclude Virtual folders
			if (!data->isFileSystemType(Virtual))
			{
				// Check to see if this file is actually on the hard disk or not
				if (isValidFileName(data->getFullPath()))
				{
					// build the from-path string
					lstrcpy(fromPathsOffset, (LPCTSTR) data->getFullPath().utf16());
					fromPathsOffset += data->getFullPath().size() + 1;

					delList.push_back(data);
				}
			}
			else
			{
				// prompt the user
				dlgManager->clearState();
				dlgManager->setCaption(QT_TR_NOOP("Remove from desktop?"));
				dlgManager->setPrompt(QT_TR_NOOP("Are you sure you want to remove %1 from your desktop?\n(You can re-enable it in Windows' Desktop Properties dialog)").arg(data->getFullPath()));
				if (dlgManager->promptDialog(DialogYesNo))
				{
					// we try and set the associated registry values for these icons
					winOS->SetIconAvailability(winOS->GetIconTypeFromFileName(data->getFullPath()), false);
					// but fade and delete the actor anyways
					FadeAndDeleteActor(data);
				}
				++numVirtualIconsDeleted;
			}
		}
	}

	if ((delList.size() + numVirtualIconsDeleted) != objList.size())
	{
		// Alert the user that one of more VIRTUAL files are in the selection
		MessageClearPolicy clearPolicy;
			clearPolicy.setTimeout(4);
		scnManager->messages()->addMessage(new Message("deleteFiles", QT_TR_NOOP("Some items cannot be deleted (ie. My Computer, Recycle Bin)\nPlease remove them through Windows' Desktop properties"), Message::Warning, clearPolicy));
	}

	if (!delList.empty())
	{
		// Delete the specific files
		fileOperation.hwnd = winOS->GetWindowsHandle();
		fileOperation.wFunc = FO_DELETE;
		fileOperation.pFrom = fromPaths;
		fileOperation.pTo = L"\0\0";
		fileOperation.fFlags = (skipRecycleBin ? 0 : FOF_ALLOWUNDO) | (confirm ? NULL : FOF_NOCONFIRMATION);

		// Remove the item form the listener before deleting
		for (uint i = 0; i < delList.size(); i++)
		{
			if (delList[i]->isPileized())
			{
				removeObject(delList[i]->getPileizedPile());
			}
		}

		SHFileOperation(&fileOperation);

		// See if there were any items that could not be deleted
		for (uint i = 0; i < delList.size(); i++)
		{
			if (isValidFileName(delList[i]->getFullPath()))
			{
				failedObj.push_back(delList[i]);
			}else{
				delList[i]->setLinearVelocity(Vec3(0.0f));
				delList[i]->setAngularVelocity(Vec3(0.0f));
				delList[i]->putToSleep();
			}
		}
	}

	delete fromPaths;
	return failedObj.size() == 0;
}
Exemplo n.º 24
0
void ProcessMessage(PDATA pdata)
{
    GameObject* gameObject;
    
    // ***** lock mutex
    pthread_mutex_lock(pdata->lock);
    Server*  server = pdata->server;
    // unlock mutex *****
    pthread_mutex_unlock(pdata->lock);

    Message* recvMessage;
    Message  sendMessage;
    Point pt;
    int clientID;
    std::string data;
    std::string playerName;
    std::istringstream istr;
    std::ostringstream ostr;
    std::map<int, GameObject*>::iterator ii;

    // object creation parameters
    int type, objID, playerID, speed, health, attack;
    double degree, posX, posY, maxSpeed;
    
    while(pdata->isRunning && (recvMessage = server->read()))
    {
        clientID = recvMessage->getID();
        sendMessage.setID(clientID);
        
        // ***** lock mutex
        pthread_mutex_lock(pdata->lock);
        
        switch(recvMessage->getType())
        {
        case Message::CONNECTION:
            // extract ship type and player name from message data
            istr.clear();
            istr.str(recvMessage->getData());
            istr >> playerName;
            
            // check if max player is reached on server
            if(pdata->ships.size() >= 8)
            {
                data = std::string("Refused");
                if(sendMessage.setAll(data, Message::CONNECTION))
                    server->write(&sendMessage, clientID);
                break;
            }

            data = std::string("Accepted");
            // add new client to the clients map
            if(pdata->clients.count(clientID) > 0)
            {
                pdata->clients.erase(clientID);
            }
            pdata->clients[clientID] = playerName;
            
            printf("client (ID: %d) connected\n", clientID);

            if(sendMessage.setAll(data, Message::CONNECTION))
                server->write(&sendMessage, clientID);
            
            // send CREATION message for every object in the maps to the client
            for(ii = pdata->projectiles.begin(); ii != pdata->projectiles.end(); ++ii)
            {
                sendMessage.setID(((GOM_Ship*)ii->second)->getPlayerID());
                sendMessage.setAll(ii->second->toString(), Message::CREATION);
                server->write(&sendMessage, clientID);
                
                // debugging
                std::cout << ii->second->toString() << std::endl;
            }
            
            for(ii = pdata->ships.begin(); ii != pdata->ships.end(); ++ii)
            {
                sendMessage.setID(((GOM_Projectile*)ii->second)->getPlayerID());
                sendMessage.setAll(ii->second->toString(), Message::CREATION);
                server->write(&sendMessage, clientID);
                
                // debugging
                std::cout << ii->second->toString() << std::endl;
            }
            break;

        case Message::RESPAWN:
            // extract ship type from msg data
            istr.clear();
            istr.str(recvMessage->getData());
            istr >> type;

	    // get a furthest start point from other ships
            pt = getStartPoint(pdata->ships);    
            objID    = pdata->objCount++;
	    degree   = 0;
            posX     = pt.getX();
            posY     = pt.getY();
            //posX = 400 * (pdata->ships.size()+1);
            //posY = 500;
	    playerID = clientID;
            speed    = 0;
	    
	    switch(type)
	    {
	      case 0:    //Galeon
		health   = 100;     
		attack   = 30;   
		maxSpeed = 3.6;
		break;
		
	      case 1:   //Battleship
		health   = 200;     
		attack   = 50;
		maxSpeed = 2;
		break;   
		
	      case 2:   //Dingy
		health   = 5;     
		attack   = 200;
		maxSpeed = 6;
		break;
	    }

            // create the GOM_Ship object
            gameObject = new GOM_Ship(ObjectType(type), objID, degree, posX, posY,
                                   playerID, speed, health, attack, maxSpeed);

            // add the game object to the map
            if(pdata->ships.count(clientID) > 0)
            {
                delete pdata->ships[clientID];
                pdata->ships.erase(clientID);
            }
            pdata->ships[clientID] = gameObject;

            sendMessage.setID(clientID);

            //Send CREATION message to all clients
            if(sendMessage.setAll(gameObject->toString(), Message::CREATION))
            {
                server->write(&sendMessage);

                // debugging
                std::cout << "ship string for client#" << clientID << std::endl;
                std::cout << pdata->ships[clientID]->toString() << std::endl;
            }
            else
            {
                printf("ERROR(client ID: %d): unable to echo CREATION message\n");
            }
            break;

        case Message::ACTION:
            // extract projectile info from msg data
            istr.clear();
            istr.str(recvMessage->getData());
            istr >> posX >> posY >> degree;

            // create a projectile object
            objID = pdata->objCount++;
            gameObject = new GOM_Projectile(PROJECTILE, objID, degree, posX, posY,
                                            clientID, 9, 50, 10);

            // debugging
            //std::cout << "projectile (clientID:" << clientID << ") - ";
            //std::cout << gameObject->toString() << std::endl;
            //std::cout << "recved data: " << recvMessage->getData() << std::endl;
            
            // add projectile object to the projectil map
            if(pdata->projectiles.count(objID) > 0)
            {
                delete pdata->projectiles[objID];
                pdata->projectiles.erase(objID);
            }
            pdata->projectiles[objID] = gameObject;

            //Send CREATION message to all clients
            if(sendMessage.setAll(gameObject->toString(), Message::CREATION))
            {
                server->write(&sendMessage);
            }
            else
            {
                printf("ERROR(client ID: %d): unable to echo ACTION message\n");
            }
            break;

        case Message::DEATH:
            // send DELETION msg to all clients
            ostr.clear();
            ostr.str("");

            if(pdata->ships.count(clientID) > 0)
            {
                ostr << "S " << pdata->ships[clientID]->getObjID() << " 1";
                sendMessage.setAll(ostr.str(), Message::DELETION);
                server->write(&sendMessage);

                delete pdata->ships[clientID];
                pdata->ships.erase(clientID);
            }
            break;

        case Message::UPDATE:
            data = recvMessage->getData();
            
            // retrieve object's ID from the data string
            if((objID = GameObjectFactory::getObjectID(data)) == -1)
			{
				std::cout << "updated failed" << std::endl;
                break;
			}
            
            // update only if the object exists
            if(pdata->ships.count(clientID) > 0)
                pdata->ships[clientID]->update(data);

            //pdata->ships[objID]->printHitBox(std::cout);
            
            // echo the UPDATE message to all clients
            // fall through

        case Message::CHAT:
            //echo to all clients
            sendMessage = *recvMessage;
            server->write(&sendMessage);
            break;
        }// end of swtich()
        
        // unlock mutex *****
        pthread_mutex_unlock(pdata->lock);

        delete recvMessage;
    }// end of while()
}
// ---------------------------------------------------------------------------
// CAccPolAudioTopologyObjectCon::InternalizeL()
// ---------------------------------------------------------------------------
//
EXPORT_C void CAccPolAudioStreamFormatCon::InternalizeL( RReadStream& aStream )
    {
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioStreamFormatCon::InternalizeL() - Enter" );

    TUint8 objectType;
    TUint32 count;

    // This object
    SetObjectType( aStream.ReadUint8L() );

    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioStreamFormatCon::InternalizeBaseL - Object Type=%d", ObjectType() );

    count = aStream.ReadUint8L();//Number of objects inside this container
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioStreamFormatCon::InternalizeL - object count = %d",count );

    for( TInt i = 0; i < count; i++ )
        {
        objectType = aStream.ReadUint8L();
        API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioStreamFormatCon::InternalizeL - object type  = %d",objectType );

        switch( objectType )
            {
            case EAccPolAudioInputStreamObject:
                {
                CAccPolAudioStreamFormat *audioStream =
                    CAccPolAudioStreamFormat::NewLC(
                        EAccPolAudioInputStreamObject );
                audioStream->InternalizeL( aStream );
                AddL( *audioStream );
                CleanupStack::PopAndDestroy( audioStream );
                }
                break;

            case EAccPolAudioOutputStreamObject:
                {
                CAccPolAudioStreamFormat *audioStream =
                    CAccPolAudioStreamFormat::NewLC(
                        EAccPolAudioOutputStreamObject );
                audioStream->InternalizeL( aStream );
                AddL( *audioStream );
                CleanupStack::PopAndDestroy( audioStream );
                }
                break;
            default:
                {
                User::Leave( KErrNotSupported );
                }
                break;
            }
        }

    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioStreamFormatCon::InternalizeL - Return" );
    }
Exemplo n.º 26
0
 ObjectType Object::GetType() const
 {
   return ObjectType(ObjectId::Null, GetServices());
 }
Exemplo n.º 27
0
Gesture::Detected PinchZoomGesture::isRecognizedImpl(GestureContext *gestureContext)
{	
	_gestureTouchPaths = gestureContext->getActiveTouchPaths();

	DWORD time = max(_gestureTouchPaths[0]->getFirstTouchPoint().relativeTimeStamp, _gestureTouchPaths[1]->getFirstTouchPoint().relativeTimeStamp);
	TouchPoint& firstFingerPoint = _gestureTouchPaths[0]->getTouchPointAt(time);
	TouchPoint& secondFingerPoint = _gestureTouchPaths[1]->getTouchPointAt(time);

	BumpObject * firstFingerObject = firstFingerPoint.getPickedObject();
	BumpObject * secondFingerObject = secondFingerPoint.getPickedObject();

	_cumulativeScaleFactor = 1.0f;
	float initialDistanceBetweenFingers = firstFingerPoint.calculateDisplacementFrom(secondFingerPoint).magnitude();

	TouchPoint& firstFingerEndPoint = _gestureTouchPaths[0]->getLastTouchPoint();
	TouchPoint& secondFingerEndPoint = _gestureTouchPaths[1]->getLastTouchPoint();

	float finalDistanceBetweenFingers = firstFingerEndPoint.calculateDisplacementFrom(secondFingerEndPoint).magnitude();

	if (abs(initialDistanceBetweenFingers - finalDistanceBetweenFingers) < MINIMUM_PATH_LENGTH)
		return Maybe;
	
	BumpObject *targetObject; // Using its plane to calculate world space distance for scaling

	if (firstFingerObject && firstFingerObject == secondFingerObject)
	{ // If both fingers are on the same object, user wants to zoom that object, so add it to selection
		targetObject = firstFingerObject;
		_pathOfTranslationPoint = _gestureTouchPaths[0];
	}	
	else if (firstFingerObject && !secondFingerObject)
	{ // If only first finger is on an object, zoom based on that object
		targetObject = firstFingerObject;
		_pathOfTranslationPoint = _gestureTouchPaths[0];
	}
	else if (secondFingerObject && !firstFingerObject)
	{ // If only second finger is on an object, zoom based on that object
		targetObject = secondFingerObject;
		_pathOfTranslationPoint = _gestureTouchPaths[1];
	}
	else
	{
		return gestureRejected("Fingers are on diff't objs, or no objs (probably camera zoom)");
	}

	if (!sel->isInSelection(targetObject))
		sel->add(targetObject);
	sel->setPickedActor(targetObject); // Set the picked object for selection to allow dragging

	//Work with the bottom most object in the pile if this is a pile
	if(targetObject->getObjectType() == ObjectType(BumpPile))
		targetObject = ((Pile *) targetObject)->getPileItems().back();

	//Calculate the normal and center point of the object
	Vec3 normal = targetObject->getGlobalOrientation() * Vec3(0.0f, 0.0f, 1.0f);
	Vec3 centerPoint = targetObject->getGlobalPosition() + (targetObject->getGlobalOrientation() * Vec3(0.0f, 0.0f, targetObject->getDims().z));

	// Create the plane representing the surface of the object and using that,
	// Find the distance between the two touch points on that plane, for scaling in world space
	_objectPlane = NxPlane(centerPoint, normal);
	_originalDistanceBetweenPoints = getDistanceInObjectPlane(firstFingerEndPoint, secondFingerEndPoint, _objectPlane);

	// Take a snapshot of the currently selected objects
	vector<BumpObject *> selected = sel->getBumpObjects();

	ObjectType griddedPile(BumpPile, SoftPile | HardPile, Grid);

	vector<BumpObject *>::iterator it;
	for(it = selected.begin(); it != selected.end(); it++)
	{
		BumpObject* obj = *it;
		if (obj->isObjectType(griddedPile) || obj->isParentType(griddedPile))
			continue;
		(*it)->updateReferenceDims();
		_selectedObjects.push_back(*it);
	}
	if (sel->getPickedActor())
		sel->getPickedActor()->onDragBegin();
	return gestureAccepted();
}
Exemplo n.º 28
0
//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;
    };
}
Exemplo n.º 29
0
vector<BumpObject *> FileSystemActor::onDrop(vector<BumpObject *> &objList)
{
	QString fPath;
	FileSystemActor *fsData;
	Pile *pile;
	FileSystemPile *fsPile;
	Vec3 topPt;
	bool moveItem = true;
	bool operationSucceeded = false;
	vector<FileSystemActor *> failedObj, fsObjList;
	vector<BumpObject *> failedBumpObjs;
	vector<FileSystemActor *> hardPileOwners;

	if (!isSourceValid())
	{
		return objList;
	}
	else
	{	
		// Convert Piles to Free Items
		for (int i = 0; i < objList.size(); i++)
		{
			// Do Pile to free Item conversions
			if (objList[i]->getObjectType() == ObjectType(BumpPile, HardPile, Stack))
			{
				// If its a Hard Pile, get its owner and use it instead of pile members
				fsPile = (FileSystemPile *) objList[i];

				objList.erase(objList.begin() + i);
				objList.push_back(fsPile->getOwner());
				hardPileOwners.push_back(fsPile->getOwner());

				fsPile->folderize(false);

				i--;

			}else if (objList[i]->getObjectType() == ObjectType(BumpPile, SoftPile, Stack))
			{
				pile = (Pile *) objList[i];

				objList.erase(objList.begin() + i);
				i--;

				// If its a Soft Pile, use its members instead of the pile
				for (uint j = 0; j < pile->getNumItems(); j++)
				{
					objList.push_back((*pile)[j]);
				}
			}
		}

		if (isFileSystemType(Executable))
		{
			for (uint i = 0; i < objList.size(); i++)
			{
				// Create a parameter list separated by spaces
				fsData = (FileSystemActor *) objList[i];

				if (!fsData || !scnManager->containsObject(fsData))
					continue;

				fPath.append(fsData->getFullPath());
				fPath.append(" ");
			}

			// We just tossed into an executable
			// QString lnkTarget, dummyLnkArgs, lnkWorkingDir;
			QString lnkArgs = fPath;
			/*
			if (isFileSystemType(Link))
			{
				fsManager->getShortcutTarget(getFullPath(), &lnkTarget, &dummyLnkArgs, &lnkWorkingDir);
				fsManager->launchFileAsync(lnkTarget, lnkArgs, lnkWorkingDir);
			}
			else
			*/
				fsManager->launchFileAsync(filePath, lnkArgs);

		}else if (isFileSystemType(Folder))
		{
			bool itemNeedsPrompt = false;
			bool onlyPhotoFrame = true;

			int iconType = winOS->GetIconTypeFromFileName(getFullPath());
			bool isRecycleBin = iconType == RecycleBin;
			bool isMyDocuments = iconType == MyDocuments;

			// Convert BumpObject to FileSystemActors, delete WebActors since they are not FileSystemActors
			for (uint i = 0; i < objList.size(); i++)
			{
				if (objList[i]->isObjectType(ObjectType(BumpActor, Webpage)))
				{
					if (isRecycleBin)
					{
						sel->remove(objList[i]);
						objList[i]->markDragCancelled(true);
						objList[i]->onDragEnd();
						FadeAndDeleteActor((Actor *)objList[i]);
						objList.erase(objList.begin() + i);
					}
					else
						_ASSERT(0);
				}
				else
				{
					fsObjList.push_back((FileSystemActor *) objList[i]);

					if (fsObjList[i]->getObjectType() == ObjectType(BumpActor, FileSystem, PhotoFrame))
						itemNeedsPrompt = true;
					else
						onlyPhotoFrame = false;
				}
			}

			if (isFileSystemType(Virtual))
			{
				// Handle tossing into the recycle bin
				if (isRecycleBin || isMyDocuments)
				{
					if (itemNeedsPrompt)
					{
						dlgManager->clearState();
						dlgManager->setPrompt(QT_TR_NOOP("A Photo Frame was detected in the selection, would you like to delete it?"));
						dlgManager->setCaption(QT_NT("BumpTop"));

						if (dlgManager->promptDialog(DialogYesNo))
						{
							vector<FileSystemActor *>::iterator iter = fsObjList.begin();
							while (iter != fsObjList.end())
							{
								FileSystemActor * fsActor = *iter;
								if (fsActor->getObjectType() == ObjectType(BumpActor, FileSystem, PhotoFrame))
								{
									// Remove the photo frame by deferring deletion until after the anim is over
									fsActor->fadeOut();
									animManager->removeAnimation(fsActor);
									animManager->addAnimation(AnimationEntry(fsActor, (FinishedCallBack) DeleteActorAfterAnim, NULL, true));

									iter = fsObjList.erase(iter);
								}
								else
									iter++;
							}
						}
						else
						{
							vector<FileSystemActor *>::iterator iter = fsObjList.begin();
							while (iter != fsObjList.end())
							{
								FileSystemActor * fsActor = *iter;
								if (fsActor->getObjectType() == ObjectType(BumpActor, FileSystem, PhotoFrame))
								{
									failedObj.push_back(fsActor);
									iter = fsObjList.erase(iter);
								}
								else
									iter++;
							}
						}
					}

					if (!fsObjList.empty())
					{
						if (isRecycleBin)
							operationSucceeded = fsManager->deleteFiles(fsObjList, failedObj, !onlyPhotoFrame);
						else
							operationSucceeded = fsManager->moveFiles(fsObjList, winOS->GetSystemPath(iconType), failedObj, true);
					}
				}
			}else{
				if (!isCopyIntoActor(objList)) // Shift forces move, Ctrl forces copy, common root defaults to move
				{
					// Handle tossing into a regular folder
					operationSucceeded = fsManager->moveFiles(fsObjList, getTargetPath(), failedObj, true);
					if (operationSucceeded)
					{
						printUnique("FileSystemActor::onDrop", QT_TR_NOOP("%1 file(s) moved to %2").arg(fsObjList.size()).arg(getText()));
					}
				}
				else
				{
					// Handle tossing into a regular folder on another resource (will copy instead of move)
					operationSucceeded = fsManager->copyFiles(fsObjList, getTargetPath(), failedObj, true);
					if (operationSucceeded)
					{
						printUnique("FileSystemActor::onDrop", QT_TR_NOOP("%1 file(s) copied to %2").arg(fsObjList.size()).arg(getText()));
					}

					// Animate back to the original starting pose
					animateObjectsBackToPreDropPose(objList);
				}
			}
		}

		if (!operationSucceeded)
		{
			// re-pileize hard piles if move failed
			vector<FileSystemActor *>::iterator iter = hardPileOwners.begin();
			while (iter != hardPileOwners.end())
			{
				(*iter)->pileize();
				iter++;
			}
		}

		// record this drop
		statsManager->getStats().bt.interaction.dragAndDrop.toActor++;
	}

	// Convert from a list of FileSYstemActors to BumpObjects
	for (uint i = 0; i < failedObj.size(); i++)
	{
		failedBumpObjs.push_back(failedObj[i]);
	}

	return failedBumpObjs;
}
Exemplo n.º 30
0
EditModeObject::EditModeObject(void) : Object(),
									   m_gridId(0),
									   m_type(ObjectType(0))
{
}