From 55231bb8d3e1a4e2752ac3d444c4287eb0ca4e8b Mon Sep 17 00:00:00 2001 From: void_17 <61356189+void2012@users.noreply.github.com> Date: Fri, 6 Mar 2026 02:11:18 +0700 Subject: Remove AUTO_VAR macro and _toString function (#592) --- Minecraft.World/SynchedEntityData.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'Minecraft.World/SynchedEntityData.cpp') diff --git a/Minecraft.World/SynchedEntityData.cpp b/Minecraft.World/SynchedEntityData.cpp index e6bb9ec7..655fa0c3 100644 --- a/Minecraft.World/SynchedEntityData.cpp +++ b/Minecraft.World/SynchedEntityData.cpp @@ -85,11 +85,11 @@ void SynchedEntityData::checkId(int id) #if 0 if (id > MAX_ID_VALUE) { - throw new IllegalArgumentException(L"Data value id is too big with " + _toString(id) + L"! (Max is " + _toString(MAX_ID_VALUE) + L")"); + throw new IllegalArgumentException(L"Data value id is too big with " + std::to_wstring(id) + L"! (Max is " + std::to_wstring(MAX_ID_VALUE) + L")"); } if (itemsById.find(id) != itemsById.end()) { - throw new IllegalArgumentException(L"Duplicate id value for " + _toString(id) + L"!"); + throw new IllegalArgumentException(L"Duplicate id value for " + std::to_wstring(id) + L"!"); } #endif } @@ -223,12 +223,10 @@ bool SynchedEntityData::isDirty() void SynchedEntityData::pack(vector > *items, DataOutputStream *output) // TODO throws IOException { - if (items != NULL) + if (items) { - AUTO_VAR(itEnd, items->end()); - for (AUTO_VAR(it, items->begin()); it != itEnd; it++) + for (auto& dataItem : *items) { - shared_ptr dataItem = *it; writeDataItem(output, dataItem); } } @@ -311,7 +309,7 @@ void SynchedEntityData::writeDataItem(DataOutputStream *output, shared_ptrwriteByte( dataItem->getValue_byte()); - break; + break; case TYPE_INT: output->writeInt( dataItem->getValue_int()); break; @@ -324,13 +322,13 @@ void SynchedEntityData::writeDataItem(DataOutputStream *output, shared_ptrgetValue_wstring(), output); break; - case TYPE_ITEMINSTANCE: + case TYPE_ITEMINSTANCE: { shared_ptr instance = (shared_ptr )dataItem->getValue_itemInstance(); Packet::writeItem(instance, output); } break; - + default: assert(false); // 4J - not implemented break; @@ -387,7 +385,7 @@ vector > *SynchedEntityData::unpack(Data case TYPE_STRING: item = shared_ptr( new DataItem(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)) ); break; - case TYPE_ITEMINSTANCE: + case TYPE_ITEMINSTANCE: { item = shared_ptr(new DataItem(itemType, itemId, Packet::readItem(input))); } @@ -408,17 +406,14 @@ vector > *SynchedEntityData::unpack(Data /** * Assigns values from a list of data items. -* +* * @param items */ void SynchedEntityData::assignValues(vector > *items) { - AUTO_VAR(itEnd, items->end()); - for (AUTO_VAR(it, items->begin()); it != itEnd; it++) + for (auto& item : *items) { - shared_ptr item = *it; - shared_ptr itemFromId = itemsById[item->getId()]; if( itemFromId != NULL ) { @@ -479,7 +474,7 @@ int SynchedEntityData::getSizeInBytes() { case TYPE_BYTE: size += 1; - break; + break; case TYPE_SHORT: size += 2; break; -- cgit v1.2.3