diff options
| author | void_17 <heroerror3@gmail.com> | 2026-03-02 17:37:16 +0700 |
|---|---|---|
| committer | void_17 <heroerror3@gmail.com> | 2026-03-02 17:37:16 +0700 |
| commit | 119bff351450ea16ffda550b6e0f67379b29f708 (patch) | |
| tree | d9f28714afd516bc2450f33b0a77c5e05ff4de90 /Minecraft.World/SynchedEntityData.cpp | |
| parent | 8a2a62ea1d47364f802cf9aae97668bc4a7007b5 (diff) | |
Revert "shared_ptr -> std::shared_ptr"
This reverts commit 7074f35e4ba831e358117842b99ee35b87f85ae5.
Diffstat (limited to 'Minecraft.World/SynchedEntityData.cpp')
| -rw-r--r-- | Minecraft.World/SynchedEntityData.cpp | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/Minecraft.World/SynchedEntityData.cpp b/Minecraft.World/SynchedEntityData.cpp index b5f31bfa..9f1aa1f7 100644 --- a/Minecraft.World/SynchedEntityData.cpp +++ b/Minecraft.World/SynchedEntityData.cpp @@ -19,7 +19,7 @@ void SynchedEntityData::define(int id, int value) MemSect(17); checkId(id); int type = TYPE_INT; - std::shared_ptr<DataItem> dataItem = std::shared_ptr<DataItem>( new DataItem(type, id, value) ); + shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) ); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -30,7 +30,7 @@ void SynchedEntityData::define(int id, byte value) MemSect(17); checkId(id); int type = TYPE_BYTE; - std::shared_ptr<DataItem> dataItem = std::shared_ptr<DataItem>( new DataItem(type, id, value) ); + shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) ); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -41,7 +41,7 @@ void SynchedEntityData::define(int id, short value) MemSect(17); checkId(id); int type = TYPE_SHORT; - std::shared_ptr<DataItem> dataItem = std::shared_ptr<DataItem>( new DataItem(type, id, value) ); + shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) ); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -52,7 +52,7 @@ void SynchedEntityData::define(int id, const wstring& value) MemSect(17); checkId(id); int type = TYPE_STRING; - std::shared_ptr<DataItem> dataItem = std::shared_ptr<DataItem>( new DataItem(type, id, value) ); + shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, value) ); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -63,7 +63,7 @@ void SynchedEntityData::defineNULL(int id, void *pVal) MemSect(17); checkId(id); int type = TYPE_ITEMINSTANCE; - std::shared_ptr<DataItem> dataItem = std::shared_ptr<DataItem>( new DataItem(type, id, std::shared_ptr<ItemInstance>()) ); + shared_ptr<DataItem> dataItem = shared_ptr<DataItem>( new DataItem(type, id, shared_ptr<ItemInstance>()) ); itemsById[id] = dataItem; MemSect(0); m_isEmpty = false; @@ -109,7 +109,7 @@ wstring SynchedEntityData::getString(int id) return itemsById[id]->getValue_wstring(); } -std::shared_ptr<ItemInstance> SynchedEntityData::getItemInstance(int id) +shared_ptr<ItemInstance> SynchedEntityData::getItemInstance(int id) { //assert(false); // 4J - not currently implemented return itemsById[id]->getValue_itemInstance(); @@ -123,7 +123,7 @@ Pos *SynchedEntityData::getPos(int id) void SynchedEntityData::set(int id, int value) { - std::shared_ptr<DataItem> dataItem = itemsById[id]; + shared_ptr<DataItem> dataItem = itemsById[id]; // update the value if it has changed if (value != dataItem->getValue_int()) @@ -136,7 +136,7 @@ void SynchedEntityData::set(int id, int value) void SynchedEntityData::set(int id, byte value) { - std::shared_ptr<DataItem> dataItem = itemsById[id]; + shared_ptr<DataItem> dataItem = itemsById[id]; // update the value if it has changed if (value != dataItem->getValue_byte()) @@ -149,7 +149,7 @@ void SynchedEntityData::set(int id, byte value) void SynchedEntityData::set(int id, short value) { - std::shared_ptr<DataItem> dataItem = itemsById[id]; + shared_ptr<DataItem> dataItem = itemsById[id]; // update the value if it has changed if (value != dataItem->getValue_short()) @@ -162,7 +162,7 @@ void SynchedEntityData::set(int id, short value) void SynchedEntityData::set(int id, const wstring& value) { - std::shared_ptr<DataItem> dataItem = itemsById[id]; + shared_ptr<DataItem> dataItem = itemsById[id]; // update the value if it has changed if (value != dataItem->getValue_wstring()) @@ -173,9 +173,9 @@ void SynchedEntityData::set(int id, const wstring& value) } } -void SynchedEntityData::set(int id, std::shared_ptr<ItemInstance> value) +void SynchedEntityData::set(int id, shared_ptr<ItemInstance> value) { - std::shared_ptr<DataItem> dataItem = itemsById[id]; + shared_ptr<DataItem> dataItem = itemsById[id]; // update the value if it has changed if (value != dataItem->getValue_itemInstance()) @@ -197,7 +197,7 @@ bool SynchedEntityData::isDirty() return m_isDirty; } -void SynchedEntityData::pack(vector<std::shared_ptr<DataItem> > *items, DataOutputStream *output) // TODO throws IOException +void SynchedEntityData::pack(vector<shared_ptr<DataItem> > *items, DataOutputStream *output) // TODO throws IOException { if (items != NULL) @@ -205,7 +205,7 @@ void SynchedEntityData::pack(vector<std::shared_ptr<DataItem> > *items, DataOutp AUTO_VAR(itEnd, items->end()); for (AUTO_VAR(it, items->begin()); it != itEnd; it++) { - std::shared_ptr<DataItem> dataItem = *it; + shared_ptr<DataItem> dataItem = *it; writeDataItem(output, dataItem); } } @@ -214,24 +214,24 @@ void SynchedEntityData::pack(vector<std::shared_ptr<DataItem> > *items, DataOutp output->writeByte(EOF_MARKER); } -vector<std::shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::packDirty() +vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::packDirty() { - vector<std::shared_ptr<DataItem> > *result = NULL; + vector<shared_ptr<DataItem> > *result = NULL; if (m_isDirty) { AUTO_VAR(itEnd, itemsById.end()); for ( AUTO_VAR(it, itemsById.begin()); it != itEnd; it++ ) { - std::shared_ptr<DataItem> dataItem = (*it).second; + shared_ptr<DataItem> dataItem = (*it).second; if (dataItem->isDirty()) { dataItem->setDirty(false); if (result == NULL) { - result = new vector<std::shared_ptr<DataItem> >(); + result = new vector<shared_ptr<DataItem> >(); } result->push_back(dataItem); } @@ -247,7 +247,7 @@ void SynchedEntityData::packAll(DataOutputStream *output) // throws IOException AUTO_VAR(itEnd, itemsById.end()); for (AUTO_VAR(it, itemsById.begin()); it != itEnd; it++ ) { - std::shared_ptr<DataItem> dataItem = (*it).second; + shared_ptr<DataItem> dataItem = (*it).second; writeDataItem(output, dataItem); } @@ -255,18 +255,18 @@ void SynchedEntityData::packAll(DataOutputStream *output) // throws IOException output->writeByte(EOF_MARKER); } -vector<std::shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::getAll() +vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::getAll() { - vector<std::shared_ptr<DataItem> > *result = NULL; + vector<shared_ptr<DataItem> > *result = NULL; AUTO_VAR(itEnd, itemsById.end()); for (AUTO_VAR(it, itemsById.begin()); it != itEnd; it++ ) { if (result == NULL) { - result = new vector<std::shared_ptr<DataItem> >(); + result = new vector<shared_ptr<DataItem> >(); } - std::shared_ptr<DataItem> dataItem = (*it).second; + shared_ptr<DataItem> dataItem = (*it).second; result->push_back(dataItem); } @@ -274,7 +274,7 @@ vector<std::shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::getAll } -void SynchedEntityData::writeDataItem(DataOutputStream *output, std::shared_ptr<DataItem> dataItem) //throws IOException +void SynchedEntityData::writeDataItem(DataOutputStream *output, shared_ptr<DataItem> dataItem) //throws IOException { // pack type and id int header = ((dataItem->getType() << TYPE_SHIFT) | (dataItem->getId() & MAX_ID_VALUE)) & 0xff; @@ -285,7 +285,7 @@ void SynchedEntityData::writeDataItem(DataOutputStream *output, std::shared_ptr< { case TYPE_BYTE: output->writeByte( dataItem->getValue_byte()); - break; + break; case TYPE_INT: output->writeInt( dataItem->getValue_int()); break; @@ -295,23 +295,23 @@ void SynchedEntityData::writeDataItem(DataOutputStream *output, std::shared_ptr< case TYPE_STRING: Packet::writeUtf(dataItem->getValue_wstring(), output); break; - case TYPE_ITEMINSTANCE: + case TYPE_ITEMINSTANCE: { - std::shared_ptr<ItemInstance> instance = (std::shared_ptr<ItemInstance> )dataItem->getValue_itemInstance(); + shared_ptr<ItemInstance> instance = (shared_ptr<ItemInstance> )dataItem->getValue_itemInstance(); Packet::writeItem(instance, output); } break; - + default: assert(false); // 4J - not implemented break; } } -vector<std::shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(DataInputStream *input) //throws IOException +vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(DataInputStream *input) //throws IOException { - vector<std::shared_ptr<DataItem> > *result = NULL; + vector<shared_ptr<DataItem> > *result = NULL; int currentHeader = input->readByte(); @@ -320,40 +320,40 @@ vector<std::shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack if (result == NULL) { - result = new vector<std::shared_ptr<DataItem> >(); + result = new vector<shared_ptr<DataItem> >(); } // split type and id int itemType = (currentHeader & TYPE_MASK) >> TYPE_SHIFT; int itemId = (currentHeader & MAX_ID_VALUE); - std::shared_ptr<DataItem> item = std::shared_ptr<DataItem>(); + shared_ptr<DataItem> item = shared_ptr<DataItem>(); switch (itemType) { case TYPE_BYTE: { byte dataRead = input->readByte(); - item = std::shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) ); + item = shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) ); } break; case TYPE_SHORT: { short dataRead = input->readShort(); - item = std::shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) ); + item = shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) ); } break; case TYPE_INT: { int dataRead = input->readInt(); - item = std::shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) ); + item = shared_ptr<DataItem>( new DataItem(itemType, itemId, dataRead) ); } break; case TYPE_STRING: - item = std::shared_ptr<DataItem>( new DataItem(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)) ); + item = shared_ptr<DataItem>( new DataItem(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)) ); break; - case TYPE_ITEMINSTANCE: + case TYPE_ITEMINSTANCE: { - item = std::shared_ptr<DataItem>(new DataItem(itemType, itemId, Packet::readItem(input))); + item = shared_ptr<DataItem>(new DataItem(itemType, itemId, Packet::readItem(input))); } break; default: @@ -372,16 +372,16 @@ vector<std::shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack /** * Assigns values from a list of data items. -* +* * @param items */ -void SynchedEntityData::assignValues(vector<std::shared_ptr<DataItem> > *items) +void SynchedEntityData::assignValues(vector<shared_ptr<DataItem> > *items) { AUTO_VAR(itEnd, items->end()); for (AUTO_VAR(it, items->begin()); it != itEnd; it++) { - std::shared_ptr<DataItem> item = *it; + shared_ptr<DataItem> item = *it; AUTO_VAR(itemFromId, itemsById.find(item->getId())); if (itemFromId != itemsById.end() ) { @@ -418,11 +418,11 @@ bool SynchedEntityData::isEmpty() int SynchedEntityData::getSizeInBytes() { int size = 1; - + AUTO_VAR(itEnd, itemsById.end()); for (AUTO_VAR(it, itemsById.begin()); it != itEnd; it++ ) { - std::shared_ptr<DataItem> dataItem = (*it).second; + shared_ptr<DataItem> dataItem = (*it).second; size += 1; @@ -431,7 +431,7 @@ int SynchedEntityData::getSizeInBytes() { case TYPE_BYTE: size += 1; - break; + break; case TYPE_SHORT: size += 2; break; @@ -481,7 +481,7 @@ SynchedEntityData::DataItem::DataItem(int type, int id, const wstring& value) : this->dirty = true; } -SynchedEntityData::DataItem::DataItem(int type, int id, std::shared_ptr<ItemInstance> itemInstance) : type( type ), id( id ) +SynchedEntityData::DataItem::DataItem(int type, int id, shared_ptr<ItemInstance> itemInstance) : type( type ), id( id ) { this->value_itemInstance = itemInstance; this->dirty = true; @@ -512,7 +512,7 @@ void SynchedEntityData::DataItem::setValue(const wstring& value) this->value_wstring = value; } -void SynchedEntityData::DataItem::setValue(std::shared_ptr<ItemInstance> itemInstance) +void SynchedEntityData::DataItem::setValue(shared_ptr<ItemInstance> itemInstance) { this->value_itemInstance = itemInstance; } @@ -537,7 +537,7 @@ wstring SynchedEntityData::DataItem::getValue_wstring() return value_wstring; } -std::shared_ptr<ItemInstance> SynchedEntityData::DataItem::getValue_itemInstance() +shared_ptr<ItemInstance> SynchedEntityData::DataItem::getValue_itemInstance() { return value_itemInstance; } |
