int MinefieldStatePdu::getMarshalledSize() const { int marshalSize = 0; marshalSize = MinefieldFamilyPdu::getMarshalledSize(); marshalSize = marshalSize + _minefieldID.getMarshalledSize(); // _minefieldID marshalSize = marshalSize + 2; // _minefieldSequence marshalSize = marshalSize + 1; // _forceID marshalSize = marshalSize + 1; // _numberOfPerimeterPoints marshalSize = marshalSize + _minefieldType.getMarshalledSize(); // _minefieldType marshalSize = marshalSize + 2; // _numberOfMineTypes marshalSize = marshalSize + _minefieldLocation.getMarshalledSize(); // _minefieldLocation marshalSize = marshalSize + _minefieldOrientation.getMarshalledSize(); // _minefieldOrientation marshalSize = marshalSize + 2; // _appearance marshalSize = marshalSize + 2; // _protocolMode for(int idx=0; idx < _perimeterPoints.size(); idx++) { Point listElement = _perimeterPoints[idx]; marshalSize = marshalSize + listElement.getMarshalledSize(); } for(int idx=0; idx < _mineType.size(); idx++) { EntityType listElement = _mineType[idx]; marshalSize = marshalSize + listElement.getMarshalledSize(); } return marshalSize; }
void MinefieldStatePdu::marshal(DataStream& dataStream) const { MinefieldFamilyPdu::marshal(dataStream); // Marshal information in superclass first _minefieldID.marshal(dataStream); dataStream << _minefieldSequence; dataStream << _forceID; dataStream << ( unsigned char )_perimeterPoints.size(); _minefieldType.marshal(dataStream); dataStream << ( unsigned short )_mineType.size(); _minefieldLocation.marshal(dataStream); _minefieldOrientation.marshal(dataStream); dataStream << _appearance; dataStream << _protocolMode; for(size_t idx = 0; idx < _perimeterPoints.size(); idx++) { Point x = _perimeterPoints[idx]; x.marshal(dataStream); } for(size_t idx = 0; idx < _mineType.size(); idx++) { EntityType x = _mineType[idx]; x.marshal(dataStream); } }
void MinefieldStatePdu::unmarshal(DataStream& dataStream) { MinefieldFamilyPdu::unmarshal(dataStream); // unmarshal information in superclass first _minefieldID.unmarshal(dataStream); dataStream >> _minefieldSequence; dataStream >> _forceID; dataStream >> _numberOfPerimeterPoints; _minefieldType.unmarshal(dataStream); dataStream >> _numberOfMineTypes; _minefieldLocation.unmarshal(dataStream); _minefieldOrientation.unmarshal(dataStream); dataStream >> _appearance; dataStream >> _protocolMode; _perimeterPoints.clear(); for(size_t idx = 0; idx < _numberOfPerimeterPoints; idx++) { Point x; x.unmarshal(dataStream); _perimeterPoints.push_back(x); } _mineType.clear(); for(size_t idx = 0; idx < _numberOfMineTypes; idx++) { EntityType x; x.unmarshal(dataStream); _mineType.push_back(x); } }
void EbuCoreMainForm::metadataProviderClosed(Operation op, QVariant value) { EntityType *entityType = QVarPtr<EntityType>::asPointer(value); if (!entityType) return; if (op == Add) m_ebuCoreMain->setMetadataProvider(entityType); m_editMetadataProvider->setText(entityType->toString()); }
void ContactDetailsTypeForm::relatedContactsFormClosed(Operation op, QVariant value) { EntityType *related = QVarPtr<EntityType>::asPointer(value); if (!related) return; if (op == Add) { m_listView->addItem(related->toString()); m_contactDetails->relatedContacts().append(related); } else if (op == Edit) { int row = m_contactDetails->relatedContacts().indexOf(related); m_listView->setItem(row, related->toString()); } }
void ContactDetailsTypeForm::relatedContactsChecked(bool checked) { if (!checked) return; m_currentEditMode = Related; updateListAndButtons(); int s = m_contactDetails->relatedContacts().size(); for (int i=0; i < s; ++i) { EntityType *rc = m_contactDetails->relatedContacts().at(i); if (!rc) continue; m_listView->addItem(rc->toString()); } }
IdType id(const EntityType& e) const { if(idSet_) return idSet_->id(e); else return this->template getMapping<EntityType::codimension>()[e.index()]; }
IdType computeId(const EntityType& e) const { IdType myId = 0; for( int c=0; c<EntityType::codimension; ++c ) myId += grid_.indexSet().size( c ); return myId + e.index(); }
void EventParagraph::read(std::istream& file) { m_position= Common::Misc::readCodedInt(file); m_length= Common::Misc::readCodedInt(file); EntityType t; t.setTypeId(static_cast<EntityTypeId>(Common::Misc::readCodedInt(file))); t.setGroupId(static_cast<EntityGroupId>(Common::Misc::readCodedInt(file))); m_evententities.first=t; int size=Common::Misc::readCodedInt(file); for (int i=0; i< size; i++) { Entity *e=new Entity(); e->read(file); m_evententities.second.push_back(e); } int other_size=Common::Misc::readCodedInt(file); for (int i=0; i< other_size; i++) { EntityType to; to.setTypeId(static_cast<EntityTypeId>(Common::Misc::readCodedInt(file))); to.setGroupId(static_cast<EntityGroupId>(Common::Misc::readCodedInt(file))); int to_size=Common::Misc::readCodedInt(file); std::vector<Entity*> v; for (int j=0; j< to_size; j++) { Entity *e=new Entity(); e->read(file); v.push_back(e); } m_otherentities[to]=v; } }
void Map::visitEntities (IEntityVisitor *visitor, const EntityType& type) { if (type == EntityType::NONE || type == EntityTypes::PLAYER) { bool needUpdate = false; for (PlayerListIter i = _players.begin(); i != _players.end();) { Player* e = *i; if (visitor->visitEntity(e)) { debug(LOG_SERVER, String::format("remove player by visit %i: %s", e->getID(), e->getType().name.c_str())); GameEvent.removeEntity(e->getVisMask(), *e); delete *i; i = _players.erase(i); needUpdate = true; } else { ++i; } } if (needUpdate) { updateVisMask(); if (_players.empty()) { resetCurrentMap(); return; } } } // changing the entities list is not allowed here. Adding or removing // would invalidate the iterators for (Map::EntityListIter i = _entities.begin(); i != _entities.end();) { IEntity* e = *i; if (type.isNone() || e->getType() == type) { if (visitor->visitEntity(e)) { debug(LOG_SERVER, String::format("remove entity by visit %i: %s", e->getID(), e->getType().name.c_str())); GameEvent.removeEntity(e->getVisMask(), *e, EntityTypes::isNpcCave(e->getType())); (*i)->prepareRemoval(); delete *i; i = _entities.erase(i); } else { ++i; } } else { ++i; } } // now we will add the newly added entities to the list to not invalidate the iterators for (Map::EntityListIter i = _entitiesToAdd.begin(); i != _entitiesToAdd.end(); ++i) { _entities.push_back(*i); } _entitiesToAdd.clear(); }
void Map::visitEntities (IEntityVisitor *visitor, const EntityType& type) { if (type == EntityType::NONE || type == EntityTypes::PLAYER) { bool needUpdate = false; for (PlayerListIter i = _players.begin(); i != _players.end();) { Player* e = *i; if (visitor->visitEntity(e)) { debug(LOG_SERVER, String::format("remove player by visit %i: %s", e->getID(), e->getType().name.c_str())); removeEntity(ClientIdToClientMask(e->getClientId()), *e); delete *i; i = _players.erase(i); needUpdate = true; } else { ++i; } } if (needUpdate) { if (_players.empty()) { resetCurrentMap(); return; } } } // changing the entities list is not allowed here. Adding or removing // would invalidate the iterators for (Map::EntityListIter i = _entities.begin(); i != _entities.end();) { IEntity* e = *i; if (type.isNone() || e->getType() == type) { if (visitor->visitEntity(e)) { debug(LOG_SERVER, String::format("remove entity by visit %i: %s", e->getID(), e->getType().name.c_str())); removeEntity(0, *e); (*i)->remove(); delete *i; i = _entities.erase(i); } else { ++i; } } else { ++i; } } }
IndexType index(const EntityType& e) const { return e.index(); }
int map (const EntityType& e) const { return e.index(); }