fix for a bug reported by zapman on blenderartist.

De-activating a loop-end actuator didnt work (it kept looping).
Looked into this further and it turns out that the actuators run with both positive and negative events false, the sound actuator assumes because its not negative that its a positive event and plays the sound anyway.

Fix by checking that its a positive event before playing.

The size limit on the message actuator was 100 which broke some scripts, set to 16384 instead.
This commit is contained in:
Campbell Barton 2009-06-17 12:32:28 +00:00
parent 2519da917a
commit 95335af1b9
2 changed files with 14 additions and 4 deletions

@ -151,7 +151,7 @@ PyAttributeDef KX_NetworkMessageActuator::Attributes[] = {
KX_PYATTRIBUTE_STRING_RW("propName", 0, 100, false, KX_NetworkMessageActuator, m_toPropName),
KX_PYATTRIBUTE_STRING_RW("subject", 0, 100, false, KX_NetworkMessageActuator, m_subject),
KX_PYATTRIBUTE_BOOL_RW("usePropBody", KX_NetworkMessageActuator, m_bPropBody),
KX_PYATTRIBUTE_STRING_RW("body", 0, 100, false, KX_NetworkMessageActuator, m_body),
KX_PYATTRIBUTE_STRING_RW("body", 0, 16384, false, KX_NetworkMessageActuator, m_body),
{ NULL } //Sentinel
};

@ -105,6 +105,7 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
// do nothing on negative events, otherwise sounds are played twice!
bool bNegativeEvent = IsNegativeEvent();
bool bPositiveEvent = m_posevent;
RemoveAllEvents();
@ -154,8 +155,17 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
// remember that we tried to stop the actuator
m_isplaying = false;
}
else
{
#if 1
// Warning: when de-activating the actuator, after a single negative event this runs again with...
// m_posevent==false && m_posevent==false, in this case IsNegativeEvent() returns false
// and assumes this is a positive event.
// check that we actually have a positive event so as not to play sounds when being disabled.
else if(bPositiveEvent) { // <- added since 2.49
#else
else { // <- works in most cases except a loop-end sound will never stop unless
// the negative pulse is done continuesly
#endif
if (!m_isplaying)
{
switch (m_type)