mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
check if a map uses bezier curved envelopes on saving. otherwise store old, smaller envelope points
This commit is contained in:
parent
b45545e6d3
commit
17628eeca9
|
@ -179,12 +179,28 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
df.AddItem(MAPITEMTYPE_GROUP, GroupCount++, sizeof(GItem), &GItem);
|
||||
}
|
||||
|
||||
// check for bezier curve envelopes, otherwise use older, smaller envelope points
|
||||
int Version = CMapItemEnvelope_v2::CURRENT_VERSION;
|
||||
int Size = sizeof(CEnvPoint_v1);
|
||||
for(int e = 0; e < m_lEnvelopes.size(); e++)
|
||||
{
|
||||
for(int p = 0; p < m_lEnvelopes[e]->m_lPoints.size(); p++)
|
||||
{
|
||||
if(m_lEnvelopes[e]->m_lPoints[p].m_Curvetype == CURVETYPE_BEZIER)
|
||||
{
|
||||
Version = CMapItemEnvelope::CURRENT_VERSION;
|
||||
Size = sizeof(CEnvPoint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// save envelopes
|
||||
int PointCount = 0;
|
||||
for(int e = 0; e < m_lEnvelopes.size(); e++)
|
||||
{
|
||||
CMapItemEnvelope Item;
|
||||
Item.m_Version = CMapItemEnvelope::CURRENT_VERSION;
|
||||
Item.m_Version = Version;
|
||||
Item.m_Channels = m_lEnvelopes[e]->m_Channels;
|
||||
Item.m_StartPoint = PointCount;
|
||||
Item.m_NumPoints = m_lEnvelopes[e]->m_lPoints.size();
|
||||
|
@ -196,15 +212,16 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
}
|
||||
|
||||
// save points
|
||||
int TotalSize = sizeof(CEnvPoint) * PointCount;
|
||||
CEnvPoint *pPoints = (CEnvPoint *)mem_alloc(TotalSize, 1);
|
||||
PointCount = 0;
|
||||
|
||||
int TotalSize = Size * PointCount;
|
||||
unsigned char *pPoints = (unsigned char *)mem_alloc(TotalSize, 1);
|
||||
int Offset = 0;
|
||||
for(int e = 0; e < m_lEnvelopes.size(); e++)
|
||||
{
|
||||
int Count = m_lEnvelopes[e]->m_lPoints.size();
|
||||
mem_copy(&pPoints[PointCount], m_lEnvelopes[e]->m_lPoints.base_ptr(), sizeof(CEnvPoint)*Count);
|
||||
PointCount += Count;
|
||||
for(int p = 0; p < m_lEnvelopes[e]->m_lPoints.size(); p++)
|
||||
{
|
||||
mem_copy(pPoints + Offset, &(m_lEnvelopes[e]->m_lPoints[p]), Size);
|
||||
Offset += Size;
|
||||
}
|
||||
}
|
||||
|
||||
df.AddItem(MAPITEMTYPE_ENVPOINTS, 0, TotalSize, pPoints);
|
||||
|
|
Loading…
Reference in a new issue