Topic: Stoopid bug is driving me nuts...  (Read 4799 times)

0 Members and 1 Guest are viewing this topic.

Offline NuclearWessels

  • Evil Dave
  • Serverkit Development Team
  • Lt. Commander
  • *
  • Posts: 1249
  • Scripter and general nuisance
    • NukeDocs
Stoopid bug is driving me nuts...
« on: April 19, 2006, 05:39:35 pm »
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


Offline KBF-Kurok

  • Lt.
  • *
  • Posts: 829
  • Gender: Male
Re: Stoopid bug is driving me nuts...
« Reply #1 on: April 19, 2006, 05:43:41 pm »
might be silly of me but did you assign an explosive force to it in the sl. Just guessing here.

Offline NuclearWessels

  • Evil Dave
  • Serverkit Development Team
  • Lt. Commander
  • *
  • Posts: 1249
  • Scripter and general nuisance
    • NukeDocs
Re: Stoopid bug is driving me nuts...
« Reply #2 on: April 20, 2006, 10:09:17 am »

Hmmm ... seems to have been a timing issue, trying to destroy a ship too soon after creating it.  Initiating the destruct sequence about 5 seconds later works ok.  (Procrastination works!)

dave

Offline KBF-Kurok

  • Lt.
  • *
  • Posts: 829
  • Gender: Male
Re: Stoopid bug is driving me nuts...
« Reply #3 on: April 24, 2006, 05:45:39 pm »
 :thumbsup:

Offline Scott_Bruno

  • http://www.ispeedonthe405.com
  • Lt. Junior Grade
  • *
  • Posts: 33
  • Gender: Male
    • ispeedonthe405.com
Re: Stoopid bug is driving me nuts...
« Reply #4 on: June 16, 2006, 03:45:48 am »
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.

Offline NuclearWessels

  • Evil Dave
  • Serverkit Development Team
  • Lt. Commander
  • *
  • Posts: 1249
  • Scripter and general nuisance
    • NukeDocs
Re: Stoopid bug is driving me nuts...
« Reply #5 on: June 20, 2006, 07:55:45 pm »
Thanks Scott,

I'd figured something along those lines once I worked out it was a timing issue.

And roger on the order of evaluation -- that was more an artifact of tacking one experiment on top of another.  mship was actually tested non-null above this snippet, so the if (mship)'s were totally redundant   ::)  I must admit, between experiments and undocumented revisions spaced over the last three years, the code quality in my scripts has dropped to thoroughly embarassing levels.

It's great to see you in here btw - welcome back!!!!!!!!!!!!!!!
dave