* Const correctness
* Merge the conditions of nested commits git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4570 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
7fa6ce0c65
commit
921726c260
|
@ -7270,72 +7270,68 @@ BOOL structSensorDroidWeapon(STRUCTURE *psStruct, DROID *psDroid)
|
|||
|
||||
/*checks if the structure has a Counter Battery sensor attached - returns
|
||||
true if it has*/
|
||||
BOOL structCBSensor(STRUCTURE *psStruct)
|
||||
{
|
||||
if (psStruct->pStructureType->pSensor)
|
||||
BOOL structCBSensor(const STRUCTURE* psStruct)
|
||||
{
|
||||
// Super Sensor works as any type
|
||||
if ((psStruct->pStructureType->pSensor->type == INDIRECT_CB_SENSOR ||
|
||||
psStruct->pStructureType->pSensor->type == SUPER_SENSOR) &&
|
||||
psStruct->pStructureType->pSensor->location == LOC_TURRET)
|
||||
if (psStruct->pStructureType->pSensor
|
||||
&& (psStruct->pStructureType->pSensor->type == INDIRECT_CB_SENSOR
|
||||
|| psStruct->pStructureType->pSensor->type == SUPER_SENSOR)
|
||||
&& psStruct->pStructureType->pSensor->location == LOC_TURRET)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*checks if the structure has a Standard Turret sensor attached - returns
|
||||
true if it has*/
|
||||
BOOL structStandardSensor(STRUCTURE *psStruct)
|
||||
BOOL structStandardSensor(const STRUCTURE* psStruct)
|
||||
{
|
||||
if (psStruct->pStructureType->pSensor)
|
||||
{
|
||||
/*Super Sensor works as any type*/
|
||||
if ((psStruct->pStructureType->pSensor->type == STANDARD_SENSOR ||
|
||||
psStruct->pStructureType->pSensor->type == SUPER_SENSOR) &&
|
||||
psStruct->pStructureType->pSensor->location == LOC_TURRET)
|
||||
// Super Sensor works as any type
|
||||
if (psStruct->pStructureType->pSensor
|
||||
&& (psStruct->pStructureType->pSensor->type == STANDARD_SENSOR
|
||||
|| psStruct->pStructureType->pSensor->type == SUPER_SENSOR)
|
||||
&& psStruct->pStructureType->pSensor->location == LOC_TURRET)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*checks if the structure has a VTOL Intercept sensor attached - returns
|
||||
true if it has*/
|
||||
BOOL structVTOLSensor(STRUCTURE *psStruct)
|
||||
{
|
||||
if (psStruct->pStructureType->pSensor)
|
||||
BOOL structVTOLSensor(const STRUCTURE* psStruct)
|
||||
{
|
||||
// Super Sensor works as any type
|
||||
if ((psStruct->pStructureType->pSensor->type == VTOL_INTERCEPT_SENSOR ||
|
||||
psStruct->pStructureType->pSensor->type == SUPER_SENSOR) &&
|
||||
psStruct->pStructureType->pSensor->location == LOC_TURRET)
|
||||
if (psStruct->pStructureType->pSensor
|
||||
&& (psStruct->pStructureType->pSensor->type == VTOL_INTERCEPT_SENSOR
|
||||
|| psStruct->pStructureType->pSensor->type == SUPER_SENSOR)
|
||||
&& psStruct->pStructureType->pSensor->location == LOC_TURRET)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*checks if the structure has a VTOL Counter Battery sensor attached - returns
|
||||
true if it has*/
|
||||
BOOL structVTOLCBSensor(STRUCTURE *psStruct)
|
||||
{
|
||||
if (psStruct->pStructureType->pSensor)
|
||||
BOOL structVTOLCBSensor(const STRUCTURE* psStruct)
|
||||
{
|
||||
// Super Sensor works as any type
|
||||
if ((psStruct->pStructureType->pSensor->type == VTOL_CB_SENSOR ||
|
||||
psStruct->pStructureType->pSensor->type == SUPER_SENSOR) &&
|
||||
psStruct->pStructureType->pSensor->location == LOC_TURRET)
|
||||
if (psStruct->pStructureType->pSensor
|
||||
&& (psStruct->pStructureType->pSensor->type == VTOL_CB_SENSOR
|
||||
|| psStruct->pStructureType->pSensor->type == SUPER_SENSOR)
|
||||
&& psStruct->pStructureType->pSensor->location == LOC_TURRET)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -339,18 +339,18 @@ extern BOOL structSensorDroidWeapon(STRUCTURE *psStruct, DROID *psDroid);
|
|||
|
||||
/*checks if the structure has a Counter Battery sensor attached - returns
|
||||
true if it has*/
|
||||
extern BOOL structCBSensor(STRUCTURE *psStruct);
|
||||
extern BOOL structCBSensor(const STRUCTURE* psStruct);
|
||||
/*checks if the structure has a Standard Turret sensor attached - returns
|
||||
true if it has*/
|
||||
extern BOOL structStandardSensor(STRUCTURE *psStruct);
|
||||
extern BOOL structStandardSensor(const STRUCTURE* psStruct);
|
||||
|
||||
/*checks if the structure has a VTOL Intercept sensor attached - returns
|
||||
true if it has*/
|
||||
extern BOOL structVTOLSensor(STRUCTURE *psStruct);
|
||||
extern BOOL structVTOLSensor(const STRUCTURE* psStruct);
|
||||
|
||||
/*checks if the structure has a VTOL Counter Battery sensor attached - returns
|
||||
true if it has*/
|
||||
extern BOOL structVTOLCBSensor(STRUCTURE *psStruct);
|
||||
extern BOOL structVTOLCBSensor(const STRUCTURE* psStruct);
|
||||
|
||||
// return the nearest rearm pad
|
||||
// if bClear is true it tries to find the nearest clear rearm pad in
|
||||
|
|
|
@ -98,7 +98,7 @@ void visUpdateLevel(void)
|
|||
visLevelDecAcc -= visLevelDec;
|
||||
}
|
||||
|
||||
static SDWORD visObjHeight(BASE_OBJECT *psObject)
|
||||
static SDWORD visObjHeight(const BASE_OBJECT * const psObject)
|
||||
{
|
||||
SDWORD height;
|
||||
|
||||
|
@ -284,13 +284,12 @@ void visTilesUpdate(BASE_OBJECT *psObj)
|
|||
* psTarget can be any type of BASE_OBJECT (e.g. a tree).
|
||||
* struckBlock controls whether structures block LOS
|
||||
*/
|
||||
BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
||||
BOOL visibleObject(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget)
|
||||
{
|
||||
SDWORD x,y, ray;
|
||||
SDWORD xdiff,ydiff, rangeSquared;
|
||||
SDWORD range = objSensorRange(psViewer);
|
||||
SDWORD tarG, top;
|
||||
STRUCTURE *psStruct;
|
||||
|
||||
ASSERT(psViewer != NULL, "Invalid viewer pointer!");
|
||||
|
||||
|
@ -298,13 +297,18 @@ BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
switch (psViewer->type)
|
||||
{
|
||||
case OBJ_DROID:
|
||||
if (((DROID*)psViewer)->droidType == DROID_COMMAND)
|
||||
{
|
||||
const DROID * const psDroid = (const DROID *)psViewer;
|
||||
|
||||
if (psDroid->droidType == DROID_COMMAND)
|
||||
{
|
||||
range = 3 * range / 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OBJ_STRUCTURE:
|
||||
psStruct = (STRUCTURE *)psViewer;
|
||||
{
|
||||
const STRUCTURE * const psStruct = (const STRUCTURE *)psViewer;
|
||||
|
||||
// a structure that is being built cannot see anything
|
||||
if (psStruct->status != SS_BUILT)
|
||||
|
@ -312,15 +316,15 @@ BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((psStruct->pStructureType->type == REF_WALL) ||
|
||||
(psStruct->pStructureType->type == REF_WALLCORNER))
|
||||
if (psStruct->pStructureType->type == REF_WALL
|
||||
|| psStruct->pStructureType->type == REF_WALLCORNER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((structCBSensor((STRUCTURE *)psViewer) ||
|
||||
structVTOLCBSensor((STRUCTURE *)psViewer)) &&
|
||||
((STRUCTURE *)psViewer)->psTarget[0] == psTarget)
|
||||
if ((structCBSensor(psStruct)
|
||||
|| structVTOLCBSensor(psStruct))
|
||||
&& psStruct->psTarget[0] == psTarget)
|
||||
{
|
||||
// if a unit is targetted by a counter battery sensor
|
||||
// it is automatically seen
|
||||
|
@ -329,13 +333,14 @@ BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
|
||||
// increase the sensor range for AA sites
|
||||
// AA sites are defensive structures that can only shoot in the air
|
||||
if ( (psStruct->pStructureType->type == REF_DEFENSE) &&
|
||||
(asWeaponStats[psStruct->asWeaps[0].nStat].surfaceToAir == SHOOT_IN_AIR) )
|
||||
if (psStruct->pStructureType->type == REF_DEFENSE
|
||||
&& asWeaponStats[psStruct->asWeaps[0].nStat].surfaceToAir == SHOOT_IN_AIR)
|
||||
{
|
||||
range = 3 * range / 2;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ASSERT( false,
|
||||
"visibleObject: visibility checking is only implemented for"
|
||||
|
@ -351,7 +356,7 @@ BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
}
|
||||
|
||||
/* First see if the target is in sensor range */
|
||||
x = (SDWORD)psViewer->pos.x;
|
||||
x = psViewer->pos.x;
|
||||
xdiff = x - (SDWORD)psTarget->pos.x;
|
||||
if (xdiff < 0)
|
||||
{
|
||||
|
@ -363,7 +368,7 @@ BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
return false;
|
||||
}
|
||||
|
||||
y = (SDWORD)psViewer->pos.y;
|
||||
y = psViewer->pos.y;
|
||||
ydiff = y - (SDWORD)psTarget->pos.y;
|
||||
if (ydiff < 0)
|
||||
{
|
||||
|
@ -422,7 +427,7 @@ BOOL visibleObjWallBlock(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
}
|
||||
|
||||
// Find the wall that is blocking LOS to a target (if any)
|
||||
STRUCTURE* visGetBlockingWall(BASE_OBJECT* psViewer, BASE_OBJECT* psTarget)
|
||||
STRUCTURE* visGetBlockingWall(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget)
|
||||
{
|
||||
blockingWall = true;
|
||||
numWalls = 0;
|
||||
|
|
|
@ -36,7 +36,7 @@ extern void visTilesUpdate(BASE_OBJECT *psObj);
|
|||
* currently droids and structures.
|
||||
* psTarget can be any type of BASE_OBJECT (e.g. a tree).
|
||||
*/
|
||||
extern BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget);
|
||||
extern BOOL visibleObject(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget);
|
||||
|
||||
/* Check whether psViewer can see psTarget.
|
||||
* struckBlock controls whether structures block LOS
|
||||
|
@ -48,7 +48,7 @@ extern BOOL visibleObjectBlock(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget,
|
|||
extern BOOL visibleObjWallBlock(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget);
|
||||
|
||||
// Find the wall that is blocking LOS to a target (if any)
|
||||
extern STRUCTURE* visGetBlockingWall(BASE_OBJECT* psViewer, BASE_OBJECT* psTarget);
|
||||
extern STRUCTURE* visGetBlockingWall(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget);
|
||||
|
||||
extern void processVisibility(BASE_OBJECT *psCurr);
|
||||
|
||||
|
@ -99,27 +99,27 @@ static inline BOOL visObjInRange(BASE_OBJECT *psObj1, BASE_OBJECT *psObj2, SDWOR
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline int objSensorRange(BASE_OBJECT *psObj)
|
||||
static inline int objSensorRange(const BASE_OBJECT* psObj)
|
||||
{
|
||||
return psObj->sensorRange;
|
||||
}
|
||||
|
||||
static inline int objSensorPower(BASE_OBJECT *psObj)
|
||||
static inline int objSensorPower(const BASE_OBJECT* psObj)
|
||||
{
|
||||
return psObj->sensorPower;
|
||||
}
|
||||
|
||||
static inline int objJammerPower(BASE_OBJECT *psObj)
|
||||
static inline int objJammerPower(const BASE_OBJECT* psObj)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int objJammerRange(BASE_OBJECT *psObj)
|
||||
static inline int objJammerRange(const BASE_OBJECT* psObj)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int objConcealment(BASE_OBJECT *psObj)
|
||||
static inline int objConcealment(const BASE_OBJECT* psObj)
|
||||
{
|
||||
return psObj->ECMMod;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue