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; CMapItemLayerSounds *pSoundLayer = (CMapItemLayerSounds *)pLayer;
if(pSoundLayer->m_Version < 1 || pSoundLayer->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
continue;
if(pSoundLayer->m_Sound == -1) if(pSoundLayer->m_Sound == -1)
continue; continue;
@ -150,6 +153,9 @@ void CMapSounds::OnRender()
{ {
CMapItemLayerSounds *pSoundLayer = (CMapItemLayerSounds *)pLayer; 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); CSoundSource *pSources = (CSoundSource *)Layers()->Map()->GetDataSwapped(pSoundLayer->m_Data);
if(!pSources) if(!pSources)

View file

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

View file

@ -18,6 +18,7 @@ enum
LAYERTYPE_SPEEDUP, LAYERTYPE_SPEEDUP,
LAYERTYPE_SWITCH, LAYERTYPE_SWITCH,
LAYERTYPE_TUNE, LAYERTYPE_TUNE,
LAYERTYPE_SOUNDS_DEPRECATED, // deprecated! do not use this, this is just for compatibility reasons
LAYERTYPE_SOUNDS, LAYERTYPE_SOUNDS,
MAPITEMTYPE_VERSION=0, MAPITEMTYPE_VERSION=0,
@ -329,23 +330,55 @@ struct CMapItemEnvelope : public CMapItemEnvelope_v1
int m_Synchronized; 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 struct CSoundSource
{ {
CPoint m_Position; CPoint m_Position;
int m_Loop; int m_Loop;
int m_TimeDelay; // in s int m_TimeDelay; // in s
int m_FalloffDistance; int m_FalloffDistance;
int m_Falloff; // [0,255] // 0 - No falloff, 255 - full
int m_PosEnv; int m_PosEnv;
int m_PosEnvOffset; int m_PosEnvOffset;
int m_SoundEnv; int m_SoundEnv;
int m_SoundEnvOffset; int m_SoundEnvOffset;
CSoundShape m_Shape;
}; };
struct CMapItemLayerSounds struct CMapItemLayerSounds
{ {
enum { CURRENT_VERSION=1 }; enum { CURRENT_VERSION=2 };
CMapItemLayer m_Layer; CMapItemLayer m_Layer;
int m_Version; int m_Version;