@@ -630,15 +630,15 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
630
630
if (ext->SpawnManager && ext->SpawnManager ->Preparing_Count ())
631
631
return FIRE_BUSY;
632
632
633
- ObjectClass* object = Target_As_Techno (target);
633
+ TechnoClass* techno = Target_As_Techno (target);
634
+ CellClass* cptr = &Map[target->Center_Coord ()];
634
635
635
636
/* *
636
637
* If the object is completely cloaked, then you can't fire on it.
637
638
*/
638
- if (object && object->Visual_Character (true , House) == VISUAL_HIDDEN
639
- && !Map[target->Center_Coord ()].Sensed_By (static_cast <HousesType>(House->Get_Heap_ID ()))
640
- && object->Owning_House () != House
641
- && (Combat_Damage () > 0 || !object->Owning_House ()->Is_Ally (House)))
639
+ if (techno != NULL && techno->Visual_Character (true , House) == VISUAL_HIDDEN
640
+ && !cptr->Sensed_By ((HousesType)House->ID ) && techno->House != House
641
+ && (Combat_Damage () > 0 || !techno->House ->Is_Ally (House)))
642
642
{
643
643
return FIRE_CANT;
644
644
}
@@ -654,12 +654,10 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
654
654
*/
655
655
if (Is_Immobilized ())
656
656
{
657
- if (What_Am_I () != RTTI_UNIT
658
- || !(reinterpret_cast <UnitClass*>(this )->Class ->IsLargeVisceroid
659
- || reinterpret_cast <UnitClass*>(this )->Class ->IsSmallVisceroid ))
660
- {
657
+ if (Kind_Of () != RTTI_UNIT)
658
+ return FIRE_CANT;
659
+ if (!reinterpret_cast <UnitClass*>(this )->Class ->IsLargeVisceroid && !reinterpret_cast <UnitClass*>(this )->Class ->IsSmallVisceroid )
661
660
return FIRE_CANT;
662
- }
663
661
}
664
662
665
663
/* *
@@ -692,7 +690,7 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
692
690
/* *
693
691
* If the weapon is a spawner, it needs to have an object ready to spawn.
694
692
*/
695
- if (weapon && Extension::Fetch<WeaponTypeClassExtension>(weapon)->IsSpawner )
693
+ if (techno && weapon && Extension::Fetch<WeaponTypeClassExtension>(weapon)->IsSpawner )
696
694
{
697
695
const auto techno_ext = Extension::Fetch<TechnoClassExtension>(this );
698
696
@@ -738,7 +736,7 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
738
736
* Check if the unit has synchronized shooting.
739
737
*/
740
738
bool check_rearm = true ;
741
- if (which != WEAPON_SLOT_SECONDARY && What_Am_I () == RTTI_UNIT)
739
+ if (which != WEAPON_SLOT_SECONDARY && Kind_Of () == RTTI_UNIT)
742
740
{
743
741
const auto unit = reinterpret_cast <UnitClass*>(this );
744
742
const int burst = CurrentBurstIndex % weapon->Burst ;
@@ -747,7 +745,7 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
747
745
if (unit->Class ->FiringSyncFrame [burst] != -1
748
746
&& unit->FiringSyncDelay != -1 )
749
747
{
750
- if (unit->Class -> FiringSyncFrame [burst] != unit->FiringSyncDelay )
748
+ if (unit->FiringSyncDelay != unit->Class -> FiringSyncFrame [burst] )
751
749
return FIRE_REARM;
752
750
753
751
check_rearm = false ;
@@ -770,10 +768,8 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
770
768
/* *
771
769
* If the object has an armor type that this unit's warhead is forbidden to fire at, bail.
772
770
*/
773
- if (object && !Verses::Get_ForceFire (object->Techno_Type_Class ()->Armor , weapon->WarheadPtr ))
774
- {
771
+ if (techno && !Verses::Get_ForceFire (techno->Techno_Type_Class ()->Armor , weapon->WarheadPtr ))
775
772
return FIRE_ILLEGAL;
776
- }
777
773
778
774
/* *
779
775
* If there is no ammo left, then it can't fire.
@@ -784,7 +780,7 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
784
780
/* *
785
781
* If cloaked, then firing is disabled.
786
782
*/
787
- if (Cloak != UNCLOAKED && (What_Am_I () != RTTI_AIRCRAFT || Cloak == CLOAKED))
783
+ if (Cloak != UNCLOAKED && (Kind_Of () != RTTI_AIRCRAFT || Cloak == CLOAKED))
788
784
return FIRE_CLOAKED;
789
785
790
786
/* *
0 commit comments