Game Development Community

Projectile sound crashes clients and decals not show. on clients

by Eric Lafrance · in Torque Game Engine · 01/20/2004 (3:12 am) · 4 replies

When I put a sound in ProjectileData, I get some bugs.

1- The sound stops and restarts "jerks" when the projectile explodes
2- The clients don't hear the sound
3- The clients crash...

I've been able to trace problems #1 and 2, but unable for the #3 :-(

for #1, in projectile.cc, in the function void Projectile::updateSound()
...
if (mHidden && mSoundHandle != NULL_AUDIOHANDLE)
   {
	  alxStop(mSoundHandle);
      mSoundHandle = NULL_AUDIOHANDLE;
   }
   else if (!mHidden) //<------- there was just an else
...

for #2, in projectile.cc, in the function bool ProjectileData::onAdd()
...
if (!sound && soundId != 0) //<--- was missing the ! (was if (sound && soundId != 0))
      if (Sim::findObject(soundId, sound) == false)
         Con::errorf(ConsoleLogEntry::General, "ProjectileData::onAdd: Invalid packet, bad datablockid(sound): %d", soundId);
...

now, for problem #3, I can't find what makes the client crash. Anyone else has tried the projectile sound?!?

This is with the head.
Thanks

#1
01/22/2004 (12:29 am)
I found out what caused the clients to crash. It comes from the projectile decals. After some testing, I found decals to work ONLY when you are single player (no decal showing on clients). Now, when the sound was combined with the decals problem, the clients crashed. I'm going to re-list in a simplier way the 3 errors in projectile.cc to correct the problems (based on projectile.cc directly from the head as of Jan 20 2004).

in game\projectile.cc, go to function bool ProjectileData::onAdd(), lign 172
This will allow clients to hear the projectiles sound

You have:
if (sound && soundId != 0)
Change it to:
if (!sound && soundId != 0)

Now go to function bool ProjectileData::preload(bool server, char errorBuffer[256]), lign 214
This will make the decals work for the clients and also prevent them from crashing if a projectile sound is used

You have:
if(!decals && decalId != 0)
Change it to:
if(!decals[i] && decalId[i] != 0)

Now go to function void Projectile::updateSound(), lign 709
This will prevent the projectile sound from "jerking" when the projectile explodes

You have:
else
Change it to:
else if(!mHidden)

Also, go to function void Projectile::onCollision(const Point3F& hitPosition... lign 896
This will prevent to call addDecal in case we're not using any decal for that projectile (prevents an engine crash)

You have:
else
Change it to:
else if(mDataBlock->decalCount)

I think the changes above should be updated into the head.
#2
01/22/2004 (9:48 am)
If you mail me this thread, I'll see about getting it into HEAD. (My mail client is my todo list. :)
#3
04/20/2004 (11:59 am)
The "if(!decals[i] && decalId[i] != 0)" and "if(mDataBlock->decalCount)" fixes do not seems to be applied to HEAD yet, but the others do.

Just a reminder... :)
#4
04/20/2004 (12:43 pm)
Great catch Eric!....:)

Thanks!