summaryrefslogtreecommitdiff
path: root/src/nw4r/snd/snd_SeqSoundHandle.cpp
blob: a30d8f397f8538bc0a391fbe3aacadabb36f2715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "nw4r/snd/snd_SeqSoundHandle.h"

/* Original source:
 * kiwi515/ogws
 * src/nw4r/snd/snd_SeqSoundHandle.cpp
 */

/*******************************************************************************
 * headers
 */

#include "common.h" // nullptr

#include "nw4r/snd/snd_SeqSound.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "nw4r/ut/ut_RuntimeTypeInfo.h"

/*******************************************************************************
 * functions
 */

namespace nw4r { namespace snd {

SeqSoundHandle::SeqSoundHandle(SoundHandle *handle) :
	mSound	(nullptr)
{
	if (!handle)
		return;

	detail::BasicSound *basicSound = handle->detail_GetAttachedSound();
	if (!basicSound)
		return;

	if (detail::SeqSound *sound =
	        ut::DynamicCast<detail::SeqSound *>(basicSound))
	{

		mSound = sound;

		if (mSound->IsAttachedTempSpecialHandle())
			mSound->DetachTempSpecialHandle();

		mSound->mTempSpecialHandle = this;
	}
}

void SeqSoundHandle::DetachSound()
{
	if (IsAttachedSound())
	{
		if (mSound->mTempSpecialHandle == this)
			mSound->mTempSpecialHandle = nullptr;
	}

	if (mSound)
		mSound = nullptr;
}

}} // namespace nw4r::snd