Anyone ever run into a situation where they can't make a ship explode?
Here's a short snippet, I'm supposedly blowing up mship, which should have type "N-PUCK" and MineID as the custom id -- either one of those should be a match, nevermind both of them.
It's actually presenting the "match" dialogue ok, so it recognizes mship is the correct one,
but the damn thing won't blow up!
Any ONE of those three destruction lines should be sufficient ....
if ((strcmp(mship->mGetClassName(), "N-PUCK") == 0) || (mship->mGetCustomID() == MineID)) {
mship->mSetSystemHealthFromOrig( kNoWeaponHardPoint, 0.0f, kFalse );
if (mship) mship->mDestroyShip();
if (mship) mship->mDestroyShipSilently();
fMissionInfo->mDisplayMessage( ship->mGetTeam(), "...it is a match for destruction..." );
}
... arrrrrrrgghhhh ... I hate it when I'm missing something stooopid!
dave
I think that might have been a hack to stave off the 'Hand of Bethke', which if you remember would occasionally detonate a ship on startup for no good reason.
Also, if I might offer some advice: your block of code is safer and more efficient if arranged like this:
if( mship && ( (mship->mGetCustomID() == MineID) || (strcmp(mship->mGetClassName(), "N-PUCK") == 0) ) )
{
mship->mSetSystemHealthFromOrig( kNoWeaponHardPoint, 0.0f, kFalse );
mship->mDestroyShip();
mship->mDestroyShipSilently();
fMissionInfo->mDisplayMessage( ship->mGetTeam(), "...it is a match for destruction..." );
}
Conditions in an IF statement are evaluated left to right, which means a couple things here. First, by making the pointer check on mship the first condition the rest of the code is safe without requiring additional if(mship) checks within the block. If mship is NULL the whole block will be skipped. Second, comparing ints is less expensive than a string compare, so do that test before the name test.