Remove AUTO_VAR macro and _toString function (#592)
This commit is contained in:
@@ -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<int>(id) + L"! (Max is " + _toString<int>(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<int>(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<shared_ptr<DataItem> > *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> dataItem = *it;
|
||||
writeDataItem(output, dataItem);
|
||||
}
|
||||
}
|
||||
@@ -311,7 +309,7 @@ void SynchedEntityData::writeDataItem(DataOutputStream *output, shared_ptr<DataI
|
||||
{
|
||||
case TYPE_BYTE:
|
||||
output->writeByte( dataItem->getValue_byte());
|
||||
break;
|
||||
break;
|
||||
case TYPE_INT:
|
||||
output->writeInt( dataItem->getValue_int());
|
||||
break;
|
||||
@@ -324,13 +322,13 @@ void SynchedEntityData::writeDataItem(DataOutputStream *output, shared_ptr<DataI
|
||||
case TYPE_STRING:
|
||||
Packet::writeUtf(dataItem->getValue_wstring(), output);
|
||||
break;
|
||||
case TYPE_ITEMINSTANCE:
|
||||
case TYPE_ITEMINSTANCE:
|
||||
{
|
||||
shared_ptr<ItemInstance> instance = (shared_ptr<ItemInstance> )dataItem->getValue_itemInstance();
|
||||
Packet::writeItem(instance, output);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
assert(false); // 4J - not implemented
|
||||
break;
|
||||
@@ -387,7 +385,7 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
|
||||
case TYPE_STRING:
|
||||
item = shared_ptr<DataItem>( new DataItem(itemType, itemId, Packet::readUtf(input, MAX_STRING_DATA_LENGTH)) );
|
||||
break;
|
||||
case TYPE_ITEMINSTANCE:
|
||||
case TYPE_ITEMINSTANCE:
|
||||
{
|
||||
item = shared_ptr<DataItem>(new DataItem(itemType, itemId, Packet::readItem(input)));
|
||||
}
|
||||
@@ -408,17 +406,14 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
|
||||
|
||||
/**
|
||||
* Assigns values from a list of data items.
|
||||
*
|
||||
*
|
||||
* @param items
|
||||
*/
|
||||
|
||||
void SynchedEntityData::assignValues(vector<shared_ptr<DataItem> > *items)
|
||||
{
|
||||
AUTO_VAR(itEnd, items->end());
|
||||
for (AUTO_VAR(it, items->begin()); it != itEnd; it++)
|
||||
for (auto& item : *items)
|
||||
{
|
||||
shared_ptr<DataItem> item = *it;
|
||||
|
||||
shared_ptr<DataItem> 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;
|
||||
|
||||
Reference in New Issue
Block a user