rem: free_ship (DeadStarShipPtr, TRUE);
context: new_ship (PELEMENT DeadShipPtr){	STARSHIPPTR DeadStarShipPtr;	ProcessSound ((SOUND)~0);	GetElementStarShip (DeadShipPtr, &DeadStarShipPtr);	if (!(DeadShipPtr->state_flags & PLAYER_SHIP))	{		if (DeadShipPtr->life_span) /* must be pre-processing */			return;	}	else	{		BOOLEAN MusicStarted;		HELEMENT hElement, hSuccElement;		DeadStarShipPtr->ShipFacing =				DeadStarShipPtr->RaceDescPtr->ship_info.var2;		DeadStarShipPtr->special_counter =				DeadStarShipPtr->RaceDescPtr->ship_info.crew_level;		if (DeadStarShipPtr->special_counter)		{			StopMusic ();			DeadStarShipPtr->RaceDescPtr->ship_info.crew_level = 0;		}		MusicStarted = FALSE;		DeadShipPtr->turn_wait = (BYTE)(				DeadShipPtr->state_flags & (GOOD_GUY | BAD_GUY)				);		for (hElement = GetHeadElement (); hElement; hElement = hSuccElement)		{			ELEMENTPTR ElementPtr;			STARSHIPPTR StarShipPtr;			LockElement (hElement, &ElementPtr);			hSuccElement = GetSuccElement (ElementPtr);			GetElementStarShip (ElementPtr, &StarShipPtr);			if (StarShipPtr == DeadStarShipPtr)			{				SetElementStarShip (ElementPtr, 0);				if (!(ElementPtr->state_flags & CREW_OBJECT)						|| ElementPtr->preprocess_func != crew_preprocess)				{					SetPrimType (&DisplayArray[ElementPtr->PrimIndex], NO_PRIM);					ElementPtr->life_span = 0;					ElementPtr->state_flags =							NONSOLID | DISAPPEARING | FINITE_LIFE;					ElementPtr->preprocess_func =							ElementPtr->postprocess_func =							ElementPtr->death_func = 0;					ElementPtr->collision_func = 0;				}			}			if (StarShipPtr					&& (StarShipPtr->cur_status_flags & PLAY_VICTORY_DITTY))			{				MusicStarted = TRUE;				PlayMusic ((MUSIC_REF)StarShipPtr->RaceDescPtr->						ship_data.victory_ditty, FALSE, 3);				StarShipPtr->cur_status_flags &= ~PLAY_VICTORY_DITTY;			}			UnlockElement (hElement);		}		DeadShipPtr->life_span = MusicStarted ?				(ONE_SECOND * 3) / BATTLE_FRAME_RATE : 1;		DeadShipPtr->death_func = new_ship;		DeadShipPtr->preprocess_func = new_ship;		SetElementStarShip (DeadShipPtr, DeadStarShipPtr);	}	if (DeadShipPtr->life_span#if !DEMO_MODE			|| PLRPlaying ((MUSIC_REF)~0)#endif /* DEMO_MODE */			)	{		DeadShipPtr->state_flags &= ~DISAPPEARING;		++DeadShipPtr->life_span;	}	else	{		BOOLEAN RestartMusic;		StopMusic ();		StopSound ();		SetElementStarShip (DeadShipPtr, 0);		RestartMusic = OpponentAlive (DeadStarShipPtr);		free_ship (DeadStarShipPtr, TRUE);UnbatchGraphics ();		if (GetNextStarShip (DeadStarShipPtr,				WHICH_SIDE (DeadShipPtr->turn_wait)) && RestartMusic)			BattleSong (TRUE);		else if (LOBYTE (battle_counter) == 0				|| HIBYTE (battle_counter) == 0)			GLOBAL (CurrentActivity) &= ~IN_BATTLE;BatchGraphics ();	}}