Forward port more cleanups from reference count work. Add warning about pointer
cast to int which is likely to cause bugs on 64bit architectures in projectile code. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1913 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
5aa373e5b2
commit
fdfe7f0745
|
@ -138,9 +138,6 @@ static void proj_InFlightDirectFunc( PROJ_OBJECT *psObj );
|
|||
static void proj_InFlightIndirectFunc( PROJ_OBJECT *psObj );
|
||||
static void proj_ImpactFunc( PROJ_OBJECT *psObj );
|
||||
static void proj_PostImpactFunc( PROJ_OBJECT *psObj );
|
||||
|
||||
//static void proj_MachineGunInFlightFunc( PROJ_OBJECT *psObj );
|
||||
|
||||
static void proj_checkBurnDamage( BASE_OBJECT *apsList, PROJ_OBJECT *psProj,
|
||||
FIRE_BOX *pFireBox );
|
||||
|
||||
|
@ -239,6 +236,20 @@ proj_Shutdown( void )
|
|||
|
||||
/***************************************************************************/
|
||||
|
||||
static void proj_Destroy(PROJ_OBJECT *psObj)
|
||||
{
|
||||
CHECK_PROJECTILE(psObj);
|
||||
|
||||
/* WARNING WARNING: The use of (int) cast pointer here is not safe for
|
||||
* most 64-bit architectures! FIXME!! - Per */
|
||||
if (hashTable_RemoveElement(g_pProjObjTable, psObj, (int) psObj, UNUSED_KEY) == FALSE)
|
||||
{
|
||||
debug(LOG_ERROR, "proj_Destroy: couldn't remove projectile from hash table");
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
PROJ_OBJECT *
|
||||
proj_GetFirst( void )
|
||||
{
|
||||
|
@ -269,24 +280,17 @@ static void proj_UpdateKills(PROJ_OBJECT *psObj)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if(bMultiPlayer)
|
||||
{
|
||||
sendDestroyExtra(psObj->psDest,psObj->psSource);
|
||||
updateMultiStatsKills(psObj->psDest,psObj->psSource->player);
|
||||
}
|
||||
|
||||
|
||||
if(psObj->psSource->type == OBJ_DROID) /* update droid kills */
|
||||
{
|
||||
psDroid = (DROID*)psObj->psSource;
|
||||
psDroid->numKills++;
|
||||
cmdDroidUpdateKills(psDroid);
|
||||
//can't assume the sensor object is a droid - it might be a structure
|
||||
/*if (orderStateObj(psDroid, DORDER_FIRESUPPORT, (BASE_OBJECT **)&psSensor))
|
||||
{
|
||||
psSensor->numKills ++;
|
||||
}*/
|
||||
if (orderStateObj(psDroid, DORDER_FIRESUPPORT, &psSensor))
|
||||
{
|
||||
if (psSensor->type == OBJ_DROID)
|
||||
|
@ -917,7 +921,6 @@ proj_InFlightIndirectFunc( PROJ_OBJECT *psObj )
|
|||
Vector3i pos;
|
||||
float fVVert;
|
||||
BOOL bOver = FALSE;
|
||||
//Watermelon:psTempObj,psNewTarget,i,xdiff,ydiff,zdiff
|
||||
BASE_OBJECT *psTempObj;
|
||||
BASE_OBJECT *psNewTarget;
|
||||
UDWORD i;
|
||||
|
@ -1314,11 +1317,8 @@ proj_ImpactFunc( PROJ_OBJECT *psObj )
|
|||
if (psObj->psDest->type == OBJ_FEATURE &&
|
||||
((FEATURE *)psObj->psDest)->psStats->damageable == 0)
|
||||
{
|
||||
debug( LOG_NEVER, "proj_ImpactFunc: trying to damage non-damageable target,projectile removed\n");
|
||||
if ( hashTable_RemoveElement( g_pProjObjTable, psObj, (int) psObj, UNUSED_KEY ) == FALSE )
|
||||
{
|
||||
debug( LOG_ERROR, "proj_ImpactFunc: couldn't remove projectile from table\n" );
|
||||
}
|
||||
debug(LOG_NEVER, "proj_ImpactFunc: trying to damage non-damageable target,projectile removed");
|
||||
proj_Destroy(psObj);
|
||||
return;
|
||||
}
|
||||
position.x = psObj->x;
|
||||
|
@ -1363,14 +1363,11 @@ proj_ImpactFunc( PROJ_OBJECT *psObj )
|
|||
/* Do damage to the target */
|
||||
if (proj_Direct(psStats))
|
||||
{
|
||||
/*Check for Electronic Warfare damage where we know the subclass
|
||||
of the weapon*/
|
||||
if (psStats->weaponSubClass == WSC_ELECTRONIC)// && psObj->psDest->
|
||||
//type == OBJ_STRUCTURE)
|
||||
/* Check for Electronic Warfare damage where we know the subclass of the weapon */
|
||||
if (psStats->weaponSubClass == WSC_ELECTRONIC)
|
||||
{
|
||||
if (psObj->psSource)
|
||||
{
|
||||
//if (electronicDamage((STRUCTURE *)psObj->psDest, calcDamage(
|
||||
if (electronicDamage(psObj->psDest, calcDamage(weaponDamage(
|
||||
psStats,psObj->player), psStats->weaponEffect,
|
||||
psObj->psDest), psObj->player))
|
||||
|
@ -1531,10 +1528,7 @@ proj_ImpactFunc( PROJ_OBJECT *psObj )
|
|||
}
|
||||
|
||||
/* This was just a simple bullet - release it and return */
|
||||
if ( hashTable_RemoveElement( g_pProjObjTable, psObj, (int) psObj, UNUSED_KEY ) == FALSE )
|
||||
{
|
||||
debug( LOG_NEVER, "proj_ImpactFunc: couldn't remove projectile from table\n" );
|
||||
}
|
||||
proj_Destroy(psObj);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1546,7 +1540,7 @@ proj_ImpactFunc( PROJ_OBJECT *psObj )
|
|||
/* Note when it exploded for the explosion effect */
|
||||
psObj->born = gameTime;
|
||||
|
||||
/* Work out the bounding box for the blast radius */
|
||||
/* Work out the bounding box for the blast radius */
|
||||
tarX0 = (SDWORD)psObj->x - (SDWORD)psStats->radius;
|
||||
tarY0 = (SDWORD)psObj->y - (SDWORD)psStats->radius;
|
||||
tarX1 = (SDWORD)psObj->x + (SDWORD)psStats->radius;
|
||||
|
@ -1862,11 +1856,7 @@ proj_PostImpactFunc( PROJ_OBJECT *psObj )
|
|||
/* Time to finish postimpact effect? */
|
||||
if (age > (SDWORD)psStats->radiusLife && age > (SDWORD)psStats->incenTime)
|
||||
{
|
||||
if ( hashTable_RemoveElement( g_pProjObjTable, psObj,
|
||||
(int) psObj, UNUSED_KEY ) == FALSE )
|
||||
{
|
||||
debug( LOG_NEVER, "proj_PostImpactFunc: couldn't remove projectile from table\n" );
|
||||
}
|
||||
proj_Destroy(psObj);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2328,11 +2318,7 @@ static void addProjNaybor(BASE_OBJECT *psObj, UDWORD distSqr)
|
|||
/* Find all the objects close to the projectile */
|
||||
void projGetNaybors(PROJ_OBJECT *psObj)
|
||||
{
|
||||
// DROID *psCurrD;
|
||||
// STRUCTURE *psCurrS;
|
||||
// FEATURE *psCurrF;
|
||||
SDWORD xdiff, ydiff;
|
||||
// UDWORD player;
|
||||
UDWORD dx,dy, distSqr;
|
||||
//Watermelon:renamed to psTempObj from psObj
|
||||
BASE_OBJECT *psTempObj;
|
||||
|
@ -2346,8 +2332,6 @@ void projGetNaybors(PROJ_OBJECT *psObj)
|
|||
CurrentProjNaybors = (BASE_OBJECT *)psObj;
|
||||
projnayborTime = gameTime;
|
||||
|
||||
|
||||
|
||||
// reset the naybor array
|
||||
numProjNaybors = 0;
|
||||
#ifdef DEBUG
|
||||
|
|
158
src/visibility.c
158
src/visibility.c
|
@ -41,9 +41,6 @@
|
|||
#include "multiplay.h"
|
||||
#include "advvis.h"
|
||||
|
||||
|
||||
|
||||
|
||||
// accuracy for the height gradient
|
||||
#define GRAD_MUL 10000
|
||||
|
||||
|
@ -336,12 +333,7 @@ static BOOL rayLOSCallback(SDWORD x, SDWORD y, SDWORD dist)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
//#define VTRAYSTEP (NUM_RAYS/80)
|
||||
#define VTRAYSTEP (NUM_RAYS/120)
|
||||
|
||||
//SDWORD currRayAng;
|
||||
//BOOL currRayPending = FALSE;
|
||||
|
||||
#define DUPF_SCANTERRAIN 0x01
|
||||
|
||||
BOOL visTilesPending(BASE_OBJECT *psObj)
|
||||
|
@ -410,11 +402,9 @@ void visTilesUpdate(BASE_OBJECT *psObj,BOOL SpreadLoad)
|
|||
rayCast(psObj->x,psObj->y,(currRayAng+(NUM_RAYS/2)+(NUM_RAYS/4))%360, range, rayTerrainCallback);
|
||||
|
||||
psDroid->currRayAng += VTRAYSTEP;
|
||||
//DBPRINTF(("%p %d\n",psDroid,psDroid->currRayAng);
|
||||
if(psDroid->currRayAng >= (NUM_RAYS/4)) {
|
||||
psDroid->currRayAng = 0;
|
||||
psDroid->updateFlags &= ~DUPF_SCANTERRAIN;
|
||||
//DBPRINTF(("%p done\n",psDroid);
|
||||
}
|
||||
} else {
|
||||
// Do the whole circle.
|
||||
|
@ -442,7 +432,6 @@ void visTilesUpdate(BASE_OBJECT *psObj,BOOL SpreadLoad)
|
|||
* psTarget can be any type of BASE_OBJECT (e.g. a tree).
|
||||
* struckBlock controls whether structures block LOS
|
||||
*/
|
||||
//BOOL visibleObjectBlock(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget, BOOL structBlock)
|
||||
BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
||||
{
|
||||
SDWORD x,y, ray;
|
||||
|
@ -574,22 +563,6 @@ BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
// if (rangeSquared > BASE_VISIBILITY*BASE_VISIBILITY)
|
||||
// {
|
||||
/* Not automatically seen so have to check against ecm */
|
||||
// sensorPower = visCalcPower(psViewer->x,psViewer->y, psTarget->x,psTarget->y,
|
||||
// sensorPower, sensorRange);
|
||||
// lastSensorPower = senPower;
|
||||
// ecm power was already calculated in processVisiblity
|
||||
/* if (sensorPower < ecmPower)
|
||||
{
|
||||
return FALSE;
|
||||
}*/
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// lastSensorPower = MAX_SENSOR_POWER; // NOTE this was "lastSensorPower == 0" which I assume was wrong (PD)
|
||||
// }
|
||||
if (rangeSquared == 0)
|
||||
{
|
||||
// Should never be on top of each other, but ...
|
||||
|
@ -597,7 +570,6 @@ BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
}
|
||||
|
||||
// initialise the callback variables
|
||||
// startH = mapTile(x>>TILE_SHIFT,y>>TILE_SHIFT)->height * ELEVATION_SCALE;
|
||||
startH = psViewer->z;
|
||||
startH += visObjHeight(psViewer);
|
||||
currG = -UBYTE_MAX * GRAD_MUL * ELEVATION_SCALE;
|
||||
|
@ -608,50 +580,14 @@ BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
finalX = psTarget->x >> TILE_SHIFT;
|
||||
finalY = psTarget->y >> TILE_SHIFT;
|
||||
|
||||
/* if (structBlock)
|
||||
{
|
||||
// Get the objects that might intersect the rays for this quadrant
|
||||
if (ray < NUM_RAYS/2)
|
||||
{
|
||||
x1 = x - xDiff;
|
||||
x2 = x;
|
||||
}
|
||||
else
|
||||
{
|
||||
x1 = x;
|
||||
x2 = x + xDiff;
|
||||
}
|
||||
if (ray < NUM_RAYS/4 || ray > 3*NUM_RAYS/4)
|
||||
{
|
||||
y1 = y;
|
||||
y2 = y + yDiff;
|
||||
}
|
||||
else
|
||||
{
|
||||
y1 = y - yDiff;
|
||||
y2 = y;
|
||||
}
|
||||
visGetTestObjects(x1,y1, x2,y2, psViewer, psTarget);
|
||||
|
||||
// Get the objects that actually intersect the ray
|
||||
visGetRayObjects(x,y, (SDWORD)psTarget->x,(SDWORD)psTarget->y);
|
||||
}
|
||||
else*/
|
||||
{
|
||||
// don't check for any objects intersecting the ray
|
||||
numRayObjects = 0;
|
||||
}
|
||||
// don't check for any objects intersecting the ray
|
||||
numRayObjects = 0;
|
||||
|
||||
// Cast a ray from the viewer to the target
|
||||
rayCast(x,y, ray, range, rayLOSCallback);
|
||||
|
||||
// See if the target can be seen
|
||||
top = ((SDWORD)psTarget->z + visObjHeight(psTarget) - startH);
|
||||
// tarG = (top*top) * GRAD_MUL / rangeSquared;
|
||||
// if (top < 0)
|
||||
// {
|
||||
// tarG = - tarG;
|
||||
// }
|
||||
tarG = top * GRAD_MUL / lastD;
|
||||
|
||||
return tarG >= currG;
|
||||
|
@ -708,59 +644,16 @@ found:
|
|||
return psWall != NULL;;
|
||||
}
|
||||
|
||||
|
||||
/* Check whether psViewer can see psTarget.
|
||||
* psViewer should be an object that has some form of sensor,
|
||||
* currently droids and structures.
|
||||
* psTarget can be any type of BASE_OBJECT (e.g. a tree).
|
||||
*/
|
||||
/*BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
||||
{
|
||||
BOOL structBlock;
|
||||
|
||||
switch (psTarget->type)
|
||||
{
|
||||
case OBJ_DROID:
|
||||
structBlock = FALSE;
|
||||
// structBlock = TRUE;
|
||||
break;
|
||||
default:
|
||||
structBlock = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return visibleObjectBlock(psViewer,psTarget, structBlock);
|
||||
}*/
|
||||
|
||||
/*BOOL blockingTile(UDWORD x, UDWORD y)
|
||||
{
|
||||
TILE *psTile;
|
||||
|
||||
// get a pointer to the tile
|
||||
psTile = mapTile(x,y);
|
||||
|
||||
// Is it anything other than grass or sand?
|
||||
if (psTile->type != TER_GRASS && psTile->type!=TER_SAND)
|
||||
return(TRUE);
|
||||
else
|
||||
return(FALSE);
|
||||
}*/
|
||||
|
||||
/* Find out what can see this object */
|
||||
void processVisibility(BASE_OBJECT *psObj)
|
||||
{
|
||||
// DROID *psCount;
|
||||
DROID *psDroid;
|
||||
STRUCTURE *psBuilding;
|
||||
UDWORD i, maxPower, ecmPoints;
|
||||
// UDWORD currPower;
|
||||
ECM_STATS *psECMStats;
|
||||
BOOL prevVis[MAX_PLAYERS], currVis[MAX_PLAYERS];
|
||||
// SDWORD maxSensor[MAX_PLAYERS];
|
||||
SDWORD visLevel;
|
||||
// SDWORD powerRatio;
|
||||
BASE_OBJECT *psViewer;
|
||||
// BOOL changed;
|
||||
MESSAGE *psMessage;
|
||||
UDWORD player, ally;
|
||||
|
||||
|
@ -1144,53 +1037,6 @@ void visGetRayObjects(SDWORD x1,SDWORD y1, SDWORD x2,SDWORD y2)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// calculate the power at a given distance from a sensor/ecm
|
||||
/*UDWORD visCalcPower(UDWORD x1,UDWORD y1, UDWORD x2,UDWORD y2, UDWORD power, UDWORD range)
|
||||
{
|
||||
SDWORD xdiff,ydiff;
|
||||
SDWORD distSq,rangeSq, powerBoost;
|
||||
UDWORD finalPower;
|
||||
// SDWORD dist, absx,absy;
|
||||
|
||||
xdiff = (SDWORD)x1 - (SDWORD)x2;
|
||||
ydiff = (SDWORD)y1 - (SDWORD)y2;
|
||||
distSq = xdiff*xdiff + ydiff*ydiff;
|
||||
rangeSq = (SDWORD)(range*range);
|
||||
// absx = abs(xdiff);
|
||||
// absy = abs(ydiff);
|
||||
// dist = absx > absy ? absx + absy/2 : absx/2 + absy;
|
||||
|
||||
// if (dist >= range)
|
||||
// {
|
||||
// finalPower = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// finalPower = power - power * dist / range;
|
||||
// }
|
||||
|
||||
if (distSq > rangeSq)
|
||||
{
|
||||
finalPower = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// increase the power -> will be bigger than power for some of range
|
||||
// powerBoost = 3 * power / 2;
|
||||
powerBoost = power;
|
||||
finalPower = (UDWORD)(powerBoost - powerBoost * distSq / rangeSq);
|
||||
// bring the power lower than max power
|
||||
if (finalPower > power)
|
||||
{
|
||||
finalPower = power;
|
||||
}
|
||||
}
|
||||
|
||||
return finalPower;
|
||||
}*/
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// alexl's sensor range.
|
||||
|
||||
|
|
|
@ -55,9 +55,6 @@ extern BOOL visGetBlockingWall(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget, STR
|
|||
|
||||
extern void processVisibility(BASE_OBJECT *psCurr);
|
||||
|
||||
// calculate the power at a given distance from a sensor/ecm
|
||||
extern UDWORD visCalcPower(UDWORD x1,UDWORD y1, UDWORD x2,UDWORD y2, UDWORD power, UDWORD range);
|
||||
|
||||
// update the visibility reduction
|
||||
extern void visUpdateLevel(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue