@@ -851,52 +851,39 @@ void CPedSA::SetBleeding(bool bBleeding)
851851 GetPedInterface ()->pedFlags .bPedIsBleeding = bBleeding;
852852}
853853
854- bool CPedSA::IsOnFire ()
855- {
856- if (GetPedInterface ()->pFireOnPed != NULL )
857- return true ;
858- return false ;
859- }
860-
861- void CPedSA::SetOnFire (bool bOnFire)
854+ bool CPedSA::SetOnFire (bool onFire)
862855{
863856 CPedSAInterface* pInterface = GetPedInterface ();
857+ if (onFire == !!pInterface->pFireOnPed )
858+ return false ;
864859
865- if (bOnFire)
866- {
867- // If we are already on fire, don't apply a new fire
868- if (pInterface->pFireOnPed == NULL )
869- {
870- CFireManagerSA* pFireManager = static_cast <CFireManagerSA*>(pGame->GetFireManager ());
871- CFire* pFire = pFireManager->StartFire (this , NULL , (float )DEFAULT_FIRE_PARTICLE_SIZE);
860+ auto * fireManager = static_cast <CFireManagerSA*>(pGame->GetFireManager ());
872861
873- if (pFire)
874- {
875- // Start the fire
876- pFire->SetTarget (this );
877- pFire->Ignite ();
878- pFire->SetStrength (1 .0f );
879- // Attach the fire only to the player, do not let it
880- // create child fires when moving.
881- pFire->SetNumGenerationsAllowed (0 );
882- pInterface->pFireOnPed = pFire->GetInterface ();
883- }
884- }
862+ if (onFire)
863+ {
864+ CFire* fire = fireManager->StartFire (this , nullptr , static_cast <float >(DEFAULT_FIRE_PARTICLE_SIZE));
865+ if (!fire)
866+ return false ;
867+
868+ // Start the fire
869+ fire->SetTarget (this );
870+ fire->Ignite ();
871+ fire->SetStrength (1 .0f );
872+ // Attach the fire only to the player, do not let it
873+ // create child fires when moving.
874+ fire->SetNumGenerationsAllowed (0 );
875+ pInterface->pFireOnPed = fire->GetInterface ();
885876 }
886877 else
887878 {
888- // Make sure that we have some attached fire
889- if (pInterface->pFireOnPed != NULL )
890- {
891- CFireManagerSA* pFireManager = static_cast <CFireManagerSA*>(pGame->GetFireManager ());
892- CFire* pFire = pFireManager->GetFire (static_cast <CFireSAInterface*>(pInterface->pFireOnPed ));
879+ CFire* fire = fireManager->GetFire (static_cast <CFireSAInterface*>(pInterface->pFireOnPed ));
880+ if (!fire)
881+ return false ;
893882
894- if (pFire)
895- {
896- pFire->Extinguish ();
897- }
898- }
883+ fire->Extinguish ();
899884 }
885+
886+ return true ;
900887}
901888
902889void CPedSA::SetStayInSamePlace (bool bStay)
0 commit comments