#include "../../Platform/stdafx.h" #include "Attribute.h" #include "RangedAttribute.h" #include "AttributeInstance.h" #include "ModifiableAttributeInstance.h" #include "ServersideAttributeMap.h" AttributeInstance* ServersideAttributeMap::getInstance(Attribute* attribute) { return BaseAttributeMap::getInstance(attribute); } AttributeInstance* ServersideAttributeMap::getInstance(eATTRIBUTE_ID id) { AttributeInstance* result = BaseAttributeMap::getInstance(id); // 4J: Removed legacy name // If we didn't find it, search by legacy name /*if (result == NULL) { AUTO_VAR(it, attributesByLegacy.find(name)); if(it != attributesByLegacy.end()) { result = it->second; } }*/ return result; } AttributeInstance* ServersideAttributeMap::registerAttribute( Attribute* attribute) { AUTO_VAR(it, attributesById.find(attribute->getId())); if (it != attributesById.end()) { return it->second; } AttributeInstance* instance = new ModifiableAttributeInstance(this, attribute); attributesById.insert(std::pair( attribute->getId(), instance)); // 4J: Removed legacy name // If this is a ranged attribute also add to legacy name map /*RangedAttribute *rangedAttribute = dynamic_cast(attribute); if (rangedAttribute != NULL && rangedAttribute->getImportLegacyName() != L"") { attributesByLegacy.insert(std::pair(rangedAttribute->getImportLegacyName(), instance)); }*/ return instance; } void ServersideAttributeMap::onAttributeModified( ModifiableAttributeInstance* attributeInstance) { if (attributeInstance->getAttribute()->isClientSyncable()) { dirtyAttributes.insert(attributeInstance); } } std::unordered_set* ServersideAttributeMap::getDirtyAttributes() { return &dirtyAttributes; } std::unordered_set* ServersideAttributeMap::getSyncableAttributes() { std::unordered_set* result = new std::unordered_set(); std::vector atts; getAttributes(atts); for (int i = 0; i < atts.size(); i++) { AttributeInstance* instance = atts.at(i); if (instance->getAttribute()->isClientSyncable()) { result->insert(instance); } } return result; }