Skip to content

Commit

Permalink
ai.cpp: Add some missing const to type casts
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Solodovnikov <[email protected]>
  • Loading branch information
ManManson committed Jan 11, 2024
1 parent c4e3ef8 commit 5748f9d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,9 +1267,9 @@ bool validTarget(BASE_OBJECT const *psObject, BASE_OBJECT const *psTarget, int w
switch (psTarget->type)
{
case OBJ_DROID:
if (asPropulsionTypes[asPropulsionStats[((DROID *)psTarget)->asBits[COMP_PROPULSION]].propulsionType].travel == AIR)
if (asPropulsionTypes[asPropulsionStats[((const DROID *)psTarget)->asBits[COMP_PROPULSION]].propulsionType].travel == AIR)
{
if (((DROID *)psTarget)->sMove.Status != MOVEINACTIVE)
if (((const DROID *)psTarget)->sMove.Status != MOVEINACTIVE)
{
bTargetInAir = true;
}
Expand All @@ -1294,15 +1294,15 @@ bool validTarget(BASE_OBJECT const *psObject, BASE_OBJECT const *psTarget, int w
switch (psObject->type)
{
case OBJ_DROID:
if (((DROID *)psObject)->droidType == DROID_SENSOR)
if (((const DROID *)psObject)->droidType == DROID_SENSOR)
{
return !bTargetInAir; // Sensor droids should not target anything in the air.
}

// Can't attack without a weapon
if (((DROID *)psObject)->numWeaps != 0 && ((DROID *)psObject)->asWeaps[weapon_slot].nStat != 0)
if (((const DROID *)psObject)->numWeaps != 0 && ((const DROID *)psObject)->asWeaps[weapon_slot].nStat != 0)
{
surfaceToAir = asWeaponStats[((DROID *)psObject)->asWeaps[weapon_slot].nStat].surfaceToAir;
surfaceToAir = asWeaponStats[((const DROID *)psObject)->asWeaps[weapon_slot].nStat].surfaceToAir;
if (((surfaceToAir & SHOOT_IN_AIR) && bTargetInAir) || ((surfaceToAir & SHOOT_ON_GROUND) && !bTargetInAir))
{
return true;
Expand All @@ -1315,9 +1315,9 @@ bool validTarget(BASE_OBJECT const *psObject, BASE_OBJECT const *psTarget, int w
break;
case OBJ_STRUCTURE:
// Can't attack without a weapon
if (((STRUCTURE *)psObject)->numWeaps != 0 && ((STRUCTURE *)psObject)->asWeaps[weapon_slot].nStat != 0)
if (((const STRUCTURE *)psObject)->numWeaps != 0 && ((const STRUCTURE *)psObject)->asWeaps[weapon_slot].nStat != 0)
{
surfaceToAir = asWeaponStats[((STRUCTURE *)psObject)->asWeaps[weapon_slot].nStat].surfaceToAir;
surfaceToAir = asWeaponStats[((const STRUCTURE *)psObject)->asWeaps[weapon_slot].nStat].surfaceToAir;
}
else
{
Expand Down

0 comments on commit 5748f9d

Please sign in to comment.