Start adding support for custom shaped audio fields

Add version check for sound layers
This commit is contained in:
BeaR 2014-11-27 16:18:15 +01:00
parent 7b4111749a
commit d1327742e7
3 changed files with 43 additions and 1 deletions

View file

@ -63,6 +63,9 @@ void CMapSounds::OnMapLoad()
{
CMapItemLayerSounds *pSoundLayer = (CMapItemLayerSounds *)pLayer;
if(pSoundLayer->m_Version < 1 || pSoundLayer->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
continue;
if(pSoundLayer->m_Sound == -1)
continue;
@ -149,6 +152,9 @@ void CMapSounds::OnRender()
if(pLayer->m_Type == LAYERTYPE_SOUNDS)
{
CMapItemLayerSounds *pSoundLayer = (CMapItemLayerSounds *)pLayer;
if(pSoundLayer->m_Version < 1 || pSoundLayer->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
continue;
CSoundSource *pSources = (CSoundSource *)Layers()->Map()->GetDataSwapped(pSoundLayer->m_Data);

View file

@ -996,6 +996,9 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS)
{
CMapItemLayerSounds *pSoundsItem = (CMapItemLayerSounds *)pLayerItem;
if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
continue;
CLayerSounds *pSounds = new CLayerSounds;
pSounds->m_pEditor = m_pEditor;
pLayer = pSounds;

View file

@ -18,6 +18,7 @@ enum
LAYERTYPE_SPEEDUP,
LAYERTYPE_SWITCH,
LAYERTYPE_TUNE,
LAYERTYPE_SOUNDS_DEPRECATED, // deprecated! do not use this, this is just for compatibility reasons
LAYERTYPE_SOUNDS,
MAPITEMTYPE_VERSION=0,
@ -329,23 +330,55 @@ struct CMapItemEnvelope : public CMapItemEnvelope_v1
int m_Synchronized;
};
struct CSoundShape
{
enum
{
SHAPE_RECTANGLE,
SHAPE_CIRCLE,
NUM_SHAPES,
};
struct CRectangle
{
int m_PosX, m_PosY; // fxp 22.10
int m_Width, m_Height; // fxp 22.10
};
struct CCircle
{
int m_PosX, m_PosY; // fxp 22.10
int m_Radius; // fxp 22.10
};
int m_Type;
union
{
CRectangle m_Rectangle;
CCircle m_Circle;
};
};
struct CSoundSource
{
CPoint m_Position;
int m_Loop;
int m_TimeDelay; // in s
int m_FalloffDistance;
int m_Falloff; // [0,255] // 0 - No falloff, 255 - full
int m_PosEnv;
int m_PosEnvOffset;
int m_SoundEnv;
int m_SoundEnvOffset;
CSoundShape m_Shape;
};
struct CMapItemLayerSounds
{
enum { CURRENT_VERSION=1 };
enum { CURRENT_VERSION=2 };
CMapItemLayer m_Layer;
int m_Version;