Preserve old DataPack behavior when overwriting data (#848)

* Match old DataPack behavior when overwriting data

* Make RemoveItem more flexible

* Ditch implied RemoveItem behavior & asher fixes

* KyleS nits - but fixed before he says them

* Add back implicit behavior

* Update CDataPack.cpp

Committing to the spec.

* Update CDataPack.h

* fixup removing last item if explicitly requested

* Fix logic for accepting pack pos, rather than index

* Fixup IsReadable

* headache is over now
This commit is contained in:
Michael Flaherty
2018-07-14 17:00:17 -07:00
committed by Kyle Sanderson
parent e4862dade8
commit 32d12ea4a6
4 changed files with 56 additions and 6 deletions
+21
View File
@@ -223,3 +223,24 @@ void *CDataPack::ReadMemory(size_t *size) const
return ptr;
}
bool CDataPack::RemoveItem(size_t pos)
{
if (!elements.length())
{
return false;
}
if (pos == static_cast<size_t>(-1))
{
pos = position;
}
if (pos >= elements.length())
{
return false;
}
elements.remove(pos);
--position;
return true;
}