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:
committed by
Kyle Sanderson
parent
e4862dade8
commit
32d12ea4a6
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user