openclonk/src/object/C4IDList.cpp

533 lines
12 KiB
C++
Raw Normal View History

2009-05-08 13:28:41 +00:00
/*
* OpenClonk, http://www.openclonk.org
*
* Copyright (c) 1998-2000, Matthes Bender
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
2016-04-03 18:18:29 +00:00
* Copyright (c) 2009-2016, The OpenClonk Team and contributors
2009-05-08 13:28:41 +00:00
*
* Distributed under the terms of the ISC license; see accompanying file
* "COPYING" for details.
2009-05-08 13:28:41 +00:00
*
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
* See accompanying file "TRADEMARK" for details.
2009-05-08 13:28:41 +00:00
*
* To redistribute this file separately, substitute the full license texts
* for the above references.
2009-05-08 13:28:41 +00:00
*/
/* At static list of C4IDs */
#include "C4Include.h"
#include "object/C4IDList.h"
2009-05-08 13:28:41 +00:00
#include "graphics/C4Draw.h"
#include "graphics/C4GraphicsResource.h"
#include "object/C4Def.h"
#include "object/C4DefList.h"
2009-05-08 13:28:41 +00:00
C4IDListChunk::C4IDListChunk()
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// prepare list
pNext=nullptr;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
C4IDListChunk::~C4IDListChunk()
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// empty the list
Clear();
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
void C4IDListChunk::Clear()
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// kill all chunks
C4IDListChunk *pChunk=pNext,*pChunk2;
while (pChunk)
2010-03-28 18:58:01 +00:00
{
pChunk2=pChunk->pNext; pChunk->pNext=nullptr;
2009-05-08 13:28:41 +00:00
delete pChunk; pChunk=pChunk2;
}
pNext=nullptr;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
C4IDList::C4IDList() : C4IDListChunk()
2010-03-28 18:58:01 +00:00
{
Default();
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
C4IDList::C4IDList(const C4IDList &rCopy): C4IDListChunk()
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
Default();
*this = rCopy;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
C4IDList &C4IDList::operator = (const C4IDList &rCopy)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// clear previous list
Clear();
// copy primary
memcpy(this, &rCopy, sizeof(C4IDList));
// copy all chunks
C4IDListChunk *pTo=this;
for (C4IDListChunk *pFrom=rCopy.pNext; pFrom; pFrom=pFrom->pNext)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
C4IDListChunk *pNew = new C4IDListChunk(*pFrom);
pTo->pNext=pNew; pTo=pNew;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// finalize
pTo->pNext=nullptr;
2009-05-08 13:28:41 +00:00
return *this;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
C4IDList::~C4IDList()
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// destruction is done in chunk
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
void C4IDList::Clear()
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// inherited
C4IDListChunk::Clear();
// reset count
Count=0;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
bool C4IDList::IsClear() const
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
return !Count;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
C4ID C4IDList::GetID(size_t index, int32_t *ipCount) const
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// outside list?
if (!Inside<size_t>(index+1,1u,Count)) return C4ID::None;
2009-05-08 13:28:41 +00:00
// get chunk to query
const C4IDListChunk *pQueryChunk=this;
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
// query it
if (ipCount) *ipCount=pQueryChunk->Count[index];
return pQueryChunk->id[index];
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
int32_t C4IDList::GetCount(size_t index) const
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// outside list?
if (!Inside<size_t>(index+1,1u,Count)) return 0;
2009-05-08 13:28:41 +00:00
// get chunk to query
const C4IDListChunk *pQueryChunk=this;
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
// query it
return pQueryChunk->Count[index];
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
bool C4IDList::SetCount(size_t index, int32_t iCount)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// outside list?
if (!Inside<size_t>(index+1,1u,Count)) return false;
2009-05-08 13:28:41 +00:00
// get chunk to set in
C4IDListChunk *pQueryChunk=this;
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
// set it
pQueryChunk->Count[index]=iCount;
2009-05-08 13:28:41 +00:00
// success
return true;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
int32_t C4IDList::GetIDCount(C4ID c_id, int32_t iZeroDefVal) const
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// find id
const C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
if (pQueryChunk->id[cntl]==c_id)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
int32_t iCount=pQueryChunk->Count[cntl];
return iCount ? iCount : iZeroDefVal;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// none found
return 0;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
bool C4IDList::SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// find id
C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
if (pQueryChunk->id[cntl]==c_id)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk->Count[cntl]=iCount; return true;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// none found: add new
if (fAddNewID)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// if end was reached, add new chunk
if (!pQueryChunk)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
C4IDListChunk *pLast=this;
while (pLast->pNext) pLast=pLast->pNext;
pQueryChunk=new C4IDListChunk();
pLast->pNext=pQueryChunk;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// set id
pQueryChunk->id[cntl]=c_id;
pQueryChunk->Count[cntl]=iCount;
// count id!
++Count;
// success
return true;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// failure
return false;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
int32_t C4IDList::GetNumberOfIDs() const
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
return Count;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
int32_t C4IDList::GetIndex(C4ID c_id) const
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// find id in list
const C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
if (pQueryChunk->id[cntl]==c_id) return Count-cnt-1;
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// not found
return -1;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
bool C4IDList::IncreaseIDCount(C4ID c_id, bool fAddNewID, int32_t IncreaseBy, bool fRemoveEmpty)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// find id in list
C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
if (pQueryChunk->id[cntl]==c_id)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// increase count
pQueryChunk->Count[cntl]+=IncreaseBy;
// check count
if (fRemoveEmpty && !pQueryChunk->Count[cntl]) DeleteItem(Count-cnt-1);
// success
return true;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// add desired?
if (!fAddNewID) return true;
// add it
// if end was reached, add new chunk
if (!pQueryChunk)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
C4IDListChunk *pLast=this;
while (pLast->pNext) pLast=pLast->pNext;
pQueryChunk=new C4IDListChunk();
pLast->pNext=pQueryChunk;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// set id
pQueryChunk->id[cntl]=c_id;
pQueryChunk->Count[cntl]=IncreaseBy;
++Count;
// success
return true;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// Access by category-sorted index
C4ID C4IDList::GetID(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t *ipCount) const
2010-03-28 18:58:01 +00:00
{
int32_t cindex=-1;
C4Def *cDef;
if (ipCount) *ipCount=0;
2009-05-08 13:28:41 +00:00
// find id
const C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
2010-03-28 18:58:01 +00:00
{
cindex++;
if (cindex==index) { if (ipCount) *ipCount=pQueryChunk->Count[cntl]; return pQueryChunk->id[cntl]; }
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
}
2010-03-28 18:58:01 +00:00
return C4ID::None;
}
2009-05-08 13:28:41 +00:00
int32_t C4IDList::GetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index) const
2010-03-28 18:58:01 +00:00
{
int32_t cindex=-1;
C4Def *cDef;
2009-05-08 13:28:41 +00:00
const C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
2010-03-28 18:58:01 +00:00
{
cindex++;
if (cindex==index) return pQueryChunk->Count[cntl];
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
}
2010-03-28 18:58:01 +00:00
return 0;
}
2009-05-08 13:28:41 +00:00
bool C4IDList::SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount)
2010-03-28 18:58:01 +00:00
{
int32_t cindex=-1;
C4Def *cDef;
2009-05-08 13:28:41 +00:00
C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
2010-03-28 18:58:01 +00:00
{
cindex++;
if (cindex==index) { pQueryChunk->Count[cntl]=iCount; return true; }
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
}
2010-03-28 18:58:01 +00:00
return false;
}
2009-05-08 13:28:41 +00:00
int32_t C4IDList::GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const
2010-03-28 18:58:01 +00:00
{
int32_t idnum=0;
C4Def *cDef;
2009-05-08 13:28:41 +00:00
const C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
idnum++;
2009-05-08 13:28:41 +00:00
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
}
2010-03-28 18:58:01 +00:00
return idnum;
}
2009-05-08 13:28:41 +00:00
// IDList merge
bool C4IDList::Add(C4IDList &rList)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
C4IDListChunk *pQueryChunk=&rList;
size_t cnt=rList.Count,cntl=0;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
IncreaseIDCount(pQueryChunk->id[cntl], true, pQueryChunk->Count[cntl]);
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
}
2010-03-28 18:58:01 +00:00
return true;
}
2009-05-08 13:28:41 +00:00
bool C4IDList::ConsolidateValids(C4DefList &rDefs, int32_t dwCategory)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
bool fIDsRemoved=false;
C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
C4Def* pDef;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// ID does not resolve to a valid def or category is specified and def does not match category
if (!(pDef = rDefs.ID2Def(pQueryChunk->id[cntl])) || (dwCategory && !(pDef->Category & dwCategory)))
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// delete it
DeleteItem(Count-cnt-1);
// handle this list index again!
--cntl;
// something was done
fIDsRemoved=true;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
if (++cntl==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
}
2010-03-28 18:58:01 +00:00
return fIDsRemoved;
}
2009-05-08 13:28:41 +00:00
void C4IDList::Draw(C4Facet &cgo, int32_t iSelection,
2010-03-28 18:58:01 +00:00
C4DefList &rDefs, DWORD dwCategory,
bool fCounts, int32_t iAlign) const
{
2009-05-08 13:28:41 +00:00
int32_t sections = cgo.GetSectionCount();
int32_t idnum = GetNumberOfIDs(rDefs,dwCategory);
int32_t firstid = Clamp<int32_t>(iSelection-sections/2,0,std::max<int32_t>(idnum-sections,0));
2009-05-08 13:28:41 +00:00
int32_t idcount;
C4ID c_id;
C4Facet cgo2;
char buf[10];
for (int32_t cnt=0; (cnt<sections) && (c_id=GetID(rDefs,dwCategory,firstid+cnt,&idcount)); cnt++)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
cgo2 = cgo.TruncateSection(iAlign);
rDefs.Draw(c_id,cgo2,(firstid+cnt==iSelection),0);
sprintf(buf,"%dx",idcount);
2013-10-18 16:49:21 +00:00
if (fCounts) pDraw->TextOut(buf, ::GraphicsResource.FontRegular, 1.0, cgo2.Surface,cgo2.X+cgo2.Wdt-1, cgo2.Y + cgo2.Hgt - 1 - ::GraphicsResource.FontRegular.GetLineHeight(),C4Draw::DEFAULT_MESSAGE_COLOR,ARight);
2009-05-08 13:28:41 +00:00
}
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
void C4IDList::Default()
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
Clear();
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// Clear index entry and shift all entries behind down by one.
bool C4IDList::DeleteItem(size_t iIndex)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// invalid index
if (!Inside<size_t>(iIndex+1,1u,Count)) return false;
2009-05-08 13:28:41 +00:00
// get chunk to delete of
size_t index=iIndex;
C4IDListChunk *pQueryChunk=this;
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
// shift down all entries behind
size_t cnt=--Count-iIndex,cntl=index,cntl2=cntl;
C4IDListChunk *pNextChunk=pQueryChunk;
while (cnt--)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// check for list overlap
if (++cntl2==C4IDListChunkSize)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
pNextChunk=pQueryChunk->pNext;
cntl2=0;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// move down
pQueryChunk->id[cntl]=pNextChunk->id[cntl2];
pQueryChunk->Count[cntl]=pNextChunk->Count[cntl2];
// next item
pQueryChunk=pNextChunk; cntl=cntl2;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// done
return true;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
bool C4IDList::operator==(const C4IDList& rhs) const
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// compare counts
if (Count != rhs.Count) return false;
// compare all chunks
const C4IDListChunk *pChunk1 = this;
const C4IDListChunk *pChunk2 = &rhs;
int32_t cnt=Count;
while (pChunk1 && pChunk2)
2010-03-28 18:58:01 +00:00
{
if (memcmp(pChunk1->id, pChunk2->id, sizeof(C4ID)*std::min<int32_t>(cnt, C4IDListChunkSize)) ) return false;
if (memcmp(pChunk1->Count, pChunk2->Count, sizeof(int32_t)*std::min<int32_t>(cnt, C4IDListChunkSize)) ) return false;
2009-05-08 13:28:41 +00:00
pChunk1=pChunk1->pNext; pChunk2=pChunk2->pNext;
cnt-=C4IDListChunkSize;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
// equal!
return true;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
void C4IDList::CompileFunc(StdCompiler *pComp, bool fValues)
2010-03-28 18:58:01 +00:00
{
// Get compiler characteristics
bool deserializing = pComp->isDeserializer();
bool fNaming = pComp->hasNaming();
// Compiling: Clear existing data first
if (deserializing) Clear();
// Start
C4IDListChunk *pChunk = this;
size_t iNr = 0, iCNr = 0;
// Without naming: Compile Count
2009-05-08 13:28:41 +00:00
int32_t iCount = Count;
2010-03-28 18:58:01 +00:00
if (!fNaming) pComp->Value(iCount);
2009-05-08 13:28:41 +00:00
Count = iCount;
// Read
2010-03-28 18:58:01 +00:00
for (;;)
{
// Prepare compiling of single mapping
if (!deserializing)
2010-03-28 18:58:01 +00:00
{
// End of list?
2010-03-28 18:58:01 +00:00
if (iNr >= Count) break;
// End of chunk?
2010-03-28 18:58:01 +00:00
if (iCNr >= C4IDListChunkSize)
{
pChunk = pChunk->pNext;
iCNr = 0;
}
2010-03-28 18:58:01 +00:00
}
else
2010-03-28 18:58:01 +00:00
{
// End of list?
2010-03-28 18:58:01 +00:00
if (!fNaming) if (iNr >= Count) break;
// End of chunk?
2010-03-28 18:58:01 +00:00
if (iCNr >= C4IDListChunkSize)
{
pChunk = pChunk->pNext = new C4IDListChunk();
iCNr = 0;
}
2010-03-28 18:58:01 +00:00
}
2010-04-01 21:08:06 +00:00
// Separator (';')
if (iNr > 0) if (!pComp->Separator(StdCompiler::SEP_SEP2)) break;
// ID
pComp->Value(mkDefaultAdapt(pChunk->id[iCNr], C4ID::None));
// ID not valid? Note that C4ID::None is invalid.
2010-03-28 18:58:01 +00:00
if (pChunk->id[iCNr] == C4ID::None) break;
// Value: Skip this part if requested
2010-03-28 18:58:01 +00:00
if (fValues)
{
2010-04-01 21:08:06 +00:00
// Separator ('=')
if (pComp->Separator(StdCompiler::SEP_SET))
2009-05-08 13:28:41 +00:00
// Count
pComp->Value(mkDefaultAdapt(pChunk->Count[iCNr], 0));
}
else if (deserializing)
pChunk->Count[iCNr] = 0;
// Goto next entry
iNr++; iCNr++;
// Save back count
if (deserializing && fNaming) Count = iNr;
}
2010-03-28 18:58:01 +00:00
}