aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/UpdateAttributesPacket.cpp
diff options
context:
space:
mode:
authorvoid_17 <61356189+void2012@users.noreply.github.com>2026-03-06 02:11:18 +0700
committerGitHub <noreply@github.com>2026-03-06 02:11:18 +0700
commit55231bb8d3e1a4e2752ac3d444c4287eb0ca4e8b (patch)
tree953c537a5c66e328e9f4ab29626cf738112d53c0 /Minecraft.World/UpdateAttributesPacket.cpp
parent7d6658fe5b3095f35093701b5ab669ffc291e875 (diff)
Remove AUTO_VAR macro and _toString function (#592)
Diffstat (limited to 'Minecraft.World/UpdateAttributesPacket.cpp')
-rw-r--r--Minecraft.World/UpdateAttributesPacket.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/Minecraft.World/UpdateAttributesPacket.cpp b/Minecraft.World/UpdateAttributesPacket.cpp
index 45c20575..e80ebe4e 100644
--- a/Minecraft.World/UpdateAttributesPacket.cpp
+++ b/Minecraft.World/UpdateAttributesPacket.cpp
@@ -13,9 +13,8 @@ UpdateAttributesPacket::UpdateAttributesPacket(int entityId, unordered_set<Attri
{
this->entityId = entityId;
- for (AUTO_VAR(it,values->begin()); it != values->end(); ++it)
+ for (AttributeInstance *value : *values)
{
- AttributeInstance *value = *it;
unordered_set<AttributeModifier*> mods;
value->getModifiers(mods);
attributes.insert(new AttributeSnapshot(value->getAttribute()->getId(), value->getBaseValue(), &mods));
@@ -25,9 +24,9 @@ UpdateAttributesPacket::UpdateAttributesPacket(int entityId, unordered_set<Attri
UpdateAttributesPacket::~UpdateAttributesPacket()
{
// Delete modifiers - these are always copies, either on construction or on read
- for(AUTO_VAR(it,attributes.begin()); it != attributes.end(); ++it)
- {
- delete (*it);
+ for(auto& attribute : attributes)
+ {
+ delete attribute;
}
}
@@ -54,9 +53,9 @@ void UpdateAttributesPacket::read(DataInputStream *dis)
attributes.insert(new AttributeSnapshot(id, base, &modifiers));
// modifiers is copied in AttributeSnapshot ctor so delete contents
- for(AUTO_VAR(it, modifiers.begin()); it != modifiers.end(); ++it)
+ for(auto& modifier : modifiers)
{
- delete *it;
+ delete modifier;
}
}
}
@@ -66,19 +65,16 @@ void UpdateAttributesPacket::write(DataOutputStream *dos)
dos->writeInt(entityId);
dos->writeInt(attributes.size());
- for(AUTO_VAR(it, attributes.begin()); it != attributes.end(); ++it)
+ for(auto& attribute : attributes)
{
- AttributeSnapshot *attribute = (*it);
-
unordered_set<AttributeModifier *> *modifiers = attribute->getModifiers();
dos->writeShort(attribute->getId());
dos->writeDouble(attribute->getBase());
dos->writeShort(modifiers->size());
- for (AUTO_VAR(it2, modifiers->begin()); it2 != modifiers->end(); ++it2)
+ for (auto& modifier : *modifiers)
{
- AttributeModifier *modifier = (*it2);
dos->writeInt(modifier->getId());
dos->writeDouble(modifier->getAmount());
dos->writeByte(modifier->getOperation());
@@ -111,17 +107,17 @@ UpdateAttributesPacket::AttributeSnapshot::AttributeSnapshot(eATTRIBUTE_ID id, d
this->id = id;
this->base = base;
- for(AUTO_VAR(it,modifiers->begin()); it != modifiers->end(); ++it)
+ for(auto& modifier : *modifiers)
{
- this->modifiers.insert( new AttributeModifier((*it)->getId(), (*it)->getAmount(), (*it)->getOperation()));
+ this->modifiers.insert( new AttributeModifier(modifier->getId(), modifier->getAmount(), modifier->getOperation()));
}
}
UpdateAttributesPacket::AttributeSnapshot::~AttributeSnapshot()
{
- for(AUTO_VAR(it, modifiers.begin()); it != modifiers.end(); ++it)
+ for(auto& modifier : modifiers)
{
- delete (*it);
+ delete modifier;
}
}