Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
2.2 kB · 83 lines
C++
at master
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283#include "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<eATTRIBUTE_ID, AttributeInstance *>(attribute->getId(), instance)); // 4J: Removed legacy name // If this is a ranged attribute also add to legacy name map /*RangedAttribute *rangedAttribute = dynamic_cast<RangedAttribute*>(attribute); if (rangedAttribute != NULL && rangedAttribute->getImportLegacyName() != L"") { attributesByLegacy.insert(std::pair<wstring, AttributeInstance*>(rangedAttribute->getImportLegacyName(), instance)); }*/
return instance;}
void ServersideAttributeMap::onAttributeModified(ModifiableAttributeInstance *attributeInstance){ if (attributeInstance->getAttribute()->isClientSyncable()) { dirtyAttributes.insert(attributeInstance); }}
unordered_set<AttributeInstance *> *ServersideAttributeMap::getDirtyAttributes(){ return &dirtyAttributes;}
unordered_set<AttributeInstance *> *ServersideAttributeMap::getSyncableAttributes(){ unordered_set<AttributeInstance *> *result = new unordered_set<AttributeInstance *>(); vector<AttributeInstance *> 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;}