In preparation for newnet branch, turn object positions into int32 values and

introduce the new typedef Position to hold them. Patch reviewed by Cyp_.


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@10052 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2010-02-28 11:53:33 +00:00 committed by Git SVN Gateway
parent f50803b0f4
commit 5f7aea25a3
17 changed files with 101 additions and 116 deletions

View File

@ -37,8 +37,9 @@ typedef struct { int x, y; } Vector2i;
typedef struct { float x, y; } Vector2f;
typedef struct { int x, y, z; } Vector3i;
typedef struct { float x, y, z; } Vector3f;
typedef struct { uint16_t x, y, z; } Vector3uw; // Only used for basedef.h BASE_ELEMENTS1.
typedef struct { uint16_t x, y, z; } Vector3uw;
typedef Vector3i Position;
typedef Vector3uw Rotation;
/*!
* Create a Vector from x and y

View File

@ -420,6 +420,13 @@ BOOL NETVector3uw(Vector3uw* vp)
&& NETuint16_t(&vp->z));
}
BOOL NETVector3i(Vector3i* vp)
{
return (NETint32_t(&vp->x)
&& NETint32_t(&vp->y)
&& NETint32_t(&vp->z));
}
typedef enum
{
test_a,

View File

@ -92,6 +92,8 @@ do \
#endif
BOOL NETVector3uw(Vector3uw* vp);
BOOL NETVector3i(Vector3i* vp);
#define NETPosition(_pos) NETVector3i(_pos)
/**
* Get player who is the source of the current packet.

View File

@ -64,7 +64,7 @@ typedef struct _tilePos
#define BASE_ELEMENTS1(pointerType) \
OBJECT_TYPE type; /**< The type of object */ \
UDWORD id; /**< ID number of the object */ \
Vector3uw pos; /**< Position of the object */ \
Position pos; /**< Position of the object */ \
float direction; /**< Object's yaw +ve rotation around up-axis */ \
SWORD pitch; /**< Object's pitch +ve rotation around right-axis (nose up/down) */ \
UBYTE player; /**< Which player the object belongs to */ \
@ -124,13 +124,13 @@ typedef struct SpaceTime
{
uint32_t time; ///< Game time
Vector3uw pos; ///< Position of the object
Position pos; ///< Position of the object
int16_t pitch; ///< Object's pitch +ve rotation around right-axis (nose up/down)
float direction; ///< Object's yaw +ve rotation around up-axis
int16_t roll; ///< Object's roll +ve rotation around forward-axis (left wing up/down)
} SPACETIME;
static inline SPACETIME constructSpacetime(Vector3uw pos, float direction, int16_t pitch, int16_t roll, uint32_t time)
static inline SPACETIME constructSpacetime(Position pos, float direction, int16_t pitch, int16_t roll, uint32_t time)
{ // we don't support C99 struct assignments
SPACETIME ret;
ret.time = time;
@ -153,7 +153,7 @@ static inline bool isDead(const BASE_OBJECT* psObj)
return (psObj->died > NOT_CURRENT_LIST);
}
static inline int objPosDiffSq(Vector3uw pos1, Vector3uw pos2)
static inline int objPosDiffSq(Position pos1, Position pos2)
{
const int xdiff = pos1.x - pos2.x;
const int ydiff = pos1.y - pos2.y;

View File

@ -31,12 +31,12 @@ static inline float interpolateFloat(float v1, float v2, uint32_t t1, uint32_t t
return v1 + (v2 - v1) * numer/denom;
}
Vector3uw interpolatePos(Vector3uw p1, Vector3uw p2, uint32_t t1, uint32_t t2, uint32_t t)
Vector3i interpolatePos(Vector3i p1, Vector3i p2, uint32_t t1, uint32_t t2, uint32_t t)
{
Vector3uw ret = { interpolateInt(p1.x, p2.x, t1, t2, t),
interpolateInt(p1.y, p2.y, t1, t2, t),
interpolateInt(p1.z, p2.z, t1, t2, t)
};
Vector3i ret = { interpolateInt(p1.x, p2.x, t1, t2, t),
interpolateInt(p1.y, p2.y, t1, t2, t),
interpolateInt(p1.z, p2.z, t1, t2, t)
};
return ret;
}

View File

@ -40,7 +40,7 @@ static inline unsigned interpolateInt(int32_t v1, int32_t v2, uint32_t t1, uint3
}
/// Get interpolated position at time t.
Vector3uw interpolatePos(Vector3uw p1, Vector3uw p2, uint32_t t1, uint32_t t2, uint32_t t);
Vector3i interpolatePos(Vector3i p1, Vector3i p2, uint32_t t1, uint32_t t2, uint32_t t);
/// Get interpolated direction at time t.
float interpolateDirection(float v1, float v2, uint32_t t1, uint32_t t2, uint32_t t);
/// Get interpolated pitch or roll at time t.

View File

@ -132,14 +132,14 @@ BOOL sendDroidSecondary(const DROID* psDroid, SECONDARY_ORDER sec, SECONDARY_STA
uint8_t player = psDroid->player;
uint32_t droid = psDroid->id;
uint32_t body = psDroid->body;
Vector3uw pos = psDroid->pos;
Position pos = psDroid->pos;
NETuint8_t(&player);
NETuint32_t(&droid);
NETenum(&sec);
NETenum(&state);
NETuint32_t(&body);
NETVector3uw(&pos);
NETPosition(&pos);
}
return NETend();
}
@ -151,7 +151,7 @@ BOOL recvDroidSecondary()
SECONDARY_ORDER sec = DSO_ATTACK_RANGE;
SECONDARY_STATE state = DSS_NONE;
uint32_t body;
Vector3uw pos;
Position pos;
NETbeginDecode(NET_SECONDARY);
{
@ -163,7 +163,7 @@ BOOL recvDroidSecondary()
NETenum(&sec);
NETenum(&state);
NETuint32_t(&body);
NETVector3uw(&pos);
NETPosition(&pos);
// If we can not find the droid should we not ask for it?
if (!IdToDroid(droid, player, &psDroid))
@ -341,12 +341,12 @@ BOOL sendDroidDisEmbark(const DROID* psDroid, const DROID* psTransporter)
uint8_t player = psDroid->player;
uint32_t droidID = psDroid->id;
uint32_t transporterID = psTransporter->id;
Vector3uw pos = psDroid->pos;
Position pos = psDroid->pos;
NETuint8_t(&player);
NETuint32_t(&droidID);
NETuint32_t(&transporterID);
NETVector3uw(&pos);
NETPosition(&pos);
}
return NETend();
}
@ -365,12 +365,12 @@ BOOL recvDroidDisEmbark()
uint8_t player;
uint32_t droidID;
uint32_t transporterID;
Vector3uw pos;
Position pos;
NETuint8_t(&player);
NETuint32_t(&droidID);
NETuint32_t(&transporterID);
NETVector3uw(&pos);
NETPosition(&pos);
NETend();
@ -539,13 +539,13 @@ BOOL SendDroid(const DROID_TEMPLATE* pTemplate, uint32_t x, uint32_t y, uint8_t
debug(LOG_SYNC, "Droid sent with id of %u", id);
NETbeginEncode(NET_DROID, NET_ALL_PLAYERS);
{
Vector3uw pos = { x, y, 0 };
Position pos = { x, y, 0 };
uint32_t templateID = pTemplate->multiPlayerID;
uint32_t power = getPower(player);
NETuint8_t(&player);
NETuint32_t(&id);
NETVector3uw(&pos);
NETPosition(&pos);
NETuint32_t(&templateID);
NETuint32_t(&power); // update player's power as well.
NETbool(&powerCalculated);
@ -562,7 +562,7 @@ BOOL recvDroid()
DROID* psDroid;
uint8_t player;
uint32_t id;
Vector3uw pos;
Position pos;
BOOL powerCalculated;
uint32_t templateID;
uint32_t power;
@ -571,7 +571,7 @@ BOOL recvDroid()
{
NETuint8_t(&player);
NETuint32_t(&id);
NETVector3uw(&pos);
NETPosition(&pos);
NETuint32_t(&templateID);
NETuint32_t(&power);
NETbool(&powerCalculated);
@ -699,7 +699,7 @@ BOOL SendGroupOrderSelected(uint8_t player, uint32_t x, uint32_t y, const BASE_O
{
NETuint32_t(&psDroid->id);
NETuint32_t(&psDroid->body);
NETVector3uw(&psDroid->pos);
NETPosition(&psDroid->pos);
--droidCount;
}
}
@ -769,7 +769,7 @@ BOOL SendGroupOrderGroup(const DROID_GROUP* psGroup, DROID_ORDER order, uint32_t
{
NETuint32_t(&psDroid->id);
NETuint32_t(&psDroid->body);
NETVector3uw(&psDroid->pos);
NETPosition(&psDroid->pos);
}
}
return NETend();
@ -788,7 +788,7 @@ BOOL recvGroupOrder()
uint8_t droidCount, i, player;
uint32_t *droidIDs;
uint32_t *droidBodies;
Vector3uw *droidPositions;
Position *droidPositions;
NETbeginDecode(NET_GROUPORDER);
{
@ -820,7 +820,7 @@ BOOL recvGroupOrder()
droidBodies = alloca(droidCount * sizeof(uint32_t));
// Finally some space for the positions of the droids
droidPositions = alloca(droidCount * sizeof(Vector3uw));
droidPositions = alloca(droidCount * sizeof(Position));
// Retrieve the droids from the message
for (i = 0; i < droidCount; ++i)
@ -839,7 +839,7 @@ BOOL recvGroupOrder()
NETuint32_t(&droidBodies[i]);
// Get the position of the droid
NETVector3uw(&droidPositions[i]);
NETPosition(&droidPositions[i]);
}
}
NETend();
@ -857,7 +857,7 @@ BOOL recvGroupOrder()
{
DROID* psDroid;
uint32_t body = droidBodies[i];
Vector3uw pos = droidPositions[i];
Position pos = droidPositions[i];
// Retrieve the droid associated with the current ID
if (!IdToDroid(droidIDs[i], ANYPLAYER, &psDroid))

View File

@ -797,7 +797,7 @@ void processMultiPlayerArtifacts(void)
static UDWORD lastCall;
FEATURE *pF,*pFN;
UDWORD x,y,pl;
Vector3i position;
Position position;
BOOL found=false;
// only do this every now and again.
@ -817,9 +817,7 @@ void processMultiPlayerArtifacts(void)
found = objectInRange((BASE_OBJECT *)apsDroidLists[selectedPlayer], pF->pos.x, pF->pos.y, (TILE_UNITS+(TILE_UNITS/3)) );
if(found)
{
position.x = pF->pos.x; // Add an effect
position.z = pF->pos.y;
position.y = pF->pos.z;
position = pF->pos; // Add an effect
addEffect(&position,EFFECT_EXPLOSION,EXPLOSION_TYPE_DISCOVERY,false,NULL,false);
x = pF->pos.x;

View File

@ -424,7 +424,8 @@ static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset
UDWORD w = psWidget->width;
UDWORD h = psWidget->height;
STRUCTURE_STATS *stat = asStructureStats + psWidget->UserData;
Vector3i Rotation, Position;
Position position;
Vector3i rotation;
char str[3];
UDWORD scale,Radius;
@ -433,12 +434,12 @@ static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset
// draw image
pie_SetGeometricOffset( x+35 ,y+(psWidget->height/2)+9);
Rotation.x = -15;
Rotation.y = ((gameTime2/45)%360) ; //45
Rotation.z = 0;
Position.x = 0;
Position.y = 0;
Position.z = BUTTON_DEPTH*2;//getStructureStatSize(stat) * 38 * OBJECT_RADIUS;
rotation.x = -15;
rotation.y = ((gameTime2/45)%360) ; //45
rotation.z = 0;
position.x = 0;
position.y = 0;
position.z = BUTTON_DEPTH*2;//getStructureStatSize(stat) * 38 * OBJECT_RADIUS;
Radius = getStructureStatSize(stat);
if(Radius <= 128) {
@ -450,7 +451,7 @@ static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset
}
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
displayStructureStatButton(stat, &Rotation, &Position, true, scale);
displayStructureStatButton(stat, &rotation, &position, true, scale);
pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON);
// draw name

View File

@ -799,7 +799,8 @@ static void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset,
UDWORD x = xOffset+psWidget->x;
UDWORD y = yOffset+psWidget->y;
UDWORD player = psWidget->UserData; //get the in game player number.
Vector3i Rotation, Position;
Position position;
Vector3i rotation;
if( responsibleFor(player,0) )
{
@ -971,14 +972,14 @@ static void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset,
if(apsDroidLists[player])
{
pie_SetGeometricOffset( MULTIMENU_FORM_X+MULTIMENU_C1 ,y+MULTIMENU_PLAYER_H);
Rotation.x = -15;
Rotation.y = 45;
Rotation.z = 0;
Position.x = 0;
Position.y = 0;
Position.z = 2000; //scale them!
rotation.x = -15;
rotation.y = 45;
rotation.z = 0;
position.x = 0;
position.y = 0;
position.z = 2000; //scale them!
displayComponentButtonObject(apsDroidLists[player],&Rotation,&Position,false, 100);
displayComponentButtonObject(apsDroidLists[player],&rotation,&position,false, 100);
}
// clean up widgets if player leaves while menu is up.

View File

@ -136,8 +136,8 @@ void turnOffMultiMsg(BOOL bDoit)
// throw a pary when you win!
BOOL multiplayerWinSequence(BOOL firstCall)
{
static Vector3i pos;
Vector3i pos2;
static Position pos;
Position pos2;
static UDWORD last=0;
float rotAmount;
STRUCTURE *psStruct;

View File

@ -87,7 +87,7 @@ BOOL sendBuildStarted(STRUCTURE *psStruct, DROID *psDroid)
}
// Z coord
NETuint16_t(&psStruct->pos.z);
NETint32_t(&psStruct->pos.z);
return NETend();
}
@ -183,9 +183,7 @@ BOOL SendBuildFinished(STRUCTURE *psStruct)
// Along with enough info to build it (if needed)
NETuint32_t(&psStruct->pStructureType->ref);
NETuint16_t(&psStruct->pos.x);
NETuint16_t(&psStruct->pos.y);
NETuint16_t(&psStruct->pos.z);
NETPosition(&psStruct->pos);
NETuint8_t(&player);
return NETend();
}
@ -195,7 +193,7 @@ BOOL recvBuildFinished()
{
uint32_t structId;
STRUCTURE *psStruct;
uint16_t x,y,z;
int32_t x,y,z;
uint32_t type,typeindex;
uint8_t player;
uint32_t power;
@ -204,9 +202,9 @@ BOOL recvBuildFinished()
NETuint32_t(&power); // get the player's power level
NETuint32_t(&structId); // get the struct id.
NETuint32_t(&type); // Kind of building.
NETuint16_t(&x); // x pos
NETuint16_t(&y); // y pos
NETuint16_t(&z); // z pos
NETint32_t(&x); // x pos
NETint32_t(&y); // y pos
NETint32_t(&z); // z pos
NETuint8_t(&player);
NETend();
@ -393,17 +391,13 @@ BOOL recvLasSat()
psStruct = IdToStruct (id, player);
psObj = IdToPointer(targetid, targetplayer);
if( psStruct && psObj)
if (psStruct && psObj)
{
// FIXME HACK Needed since we got those ugly Vector3uw floating around in BASE_OBJECT...
Vector3i pos = Vector3uw_To3i(psObj->pos);
// Give enemy no quarter, unleash the lasat
proj_SendProjectile(&psStruct->asWeaps[0], NULL, player, pos, psObj, true, 0);
proj_SendProjectile(&psStruct->asWeaps[0], NULL, player, psObj->pos, psObj, true, 0);
// Play 5 second countdown message
audio_QueueTrackPos( ID_SOUND_LAS_SAT_COUNTDOWN, psObj->pos.x, psObj->pos.y,
psObj->pos.z);
audio_QueueTrackPos( ID_SOUND_LAS_SAT_COUNTDOWN, psObj->pos.x, psObj->pos.y, psObj->pos.z);
}
return true;

View File

@ -714,9 +714,7 @@ static BOOL sendStructureCheck(void)
NETuint32_t(&pS->id);
NETuint32_t(&pS->body);
NETuint32_t(&pS->pStructureType->ref);
NETuint16_t(&pS->pos.x);
NETuint16_t(&pS->pos.y);
NETuint16_t(&pS->pos.z);
NETPosition(&pS->pos);
NETfloat(&pS->direction);
switch (pS->pStructureType->type)

View File

@ -4331,9 +4331,6 @@ void orderStructureObj(UDWORD player, BASE_OBJECT *psObj)
{
if (lasSatStructSelected(psStruct))
{
// FIXME HACK Needed since we got those ugly Vector3uw floating around in BASE_OBJECT...
Vector3i pos = Vector3uw_To3i(psObj->pos);
// Lassats have just one weapon
unsigned int firePause = weaponFirePause(&asWeaponStats[psStruct->asWeaps[0].nStat], (UBYTE)player);
unsigned int damLevel = PERCENT(psStruct->body, structureBody(psStruct));
@ -4351,7 +4348,7 @@ void orderStructureObj(UDWORD player, BASE_OBJECT *psObj)
}
//ok to fire - so fire away
proj_SendProjectile(&psStruct->asWeaps[0], NULL, player, pos, psObj, true, 0);
proj_SendProjectile(&psStruct->asWeaps[0], NULL, player, psObj->pos, psObj, true, 0);
//set up last fires time
psStruct->asWeaps[0].lastFired = gameTime;

View File

@ -330,7 +330,7 @@ BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, Ve
SDWORD tarHeight, srcHeight, iMinSq;
SDWORD altChange, dx, dy, dz, iVelSq, iVel;
double fR, fA, fS, fT, fC;
Vector3f muzzle;
Vector3f muzzle;
SDWORD iRadSq, iPitchLow, iPitchHigh, iTemp;
WEAPON_STATS *psStats = &asWeaponStats[psWeap->nStat];
@ -343,7 +343,7 @@ BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, Ve
{
// if there isn't an attacker just start at the target position
// NB this is for the script function to fire the las sats
muzzle = Vector3f_Init(target.x, target.y, target.z);
muzzle = Vector3i_To3f(target);
}
else if (psAttacker->type == OBJ_DROID && weapon_slot >= 0)
{
@ -357,8 +357,7 @@ BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, Ve
}
else // incase anything wants a projectile
{
// FIXME HACK Needed since we got those ugly Vector3uw floating around in BASE_OBJECT...
muzzle = Vector3uw_To3f(psAttacker->pos);
muzzle = Vector3i_To3f(psAttacker->pos);
}
/* Initialise the structure */
@ -366,7 +365,7 @@ BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, Ve
psProj->type = OBJ_PROJECTILE;
psProj->psWStats = psStats;
psProj->pos = Vector3f_To3uw(muzzle);
psProj->pos = Vector3f_To3i(muzzle);
psProj->startX = muzzle.x;
psProj->startY = muzzle.y;
psProj->tarX = target.x;
@ -523,7 +522,6 @@ BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, Ve
}
/* if droid set muzzle pitch */
//Watermelon:fix turret pitch for more turrets
if (psAttacker != NULL && weapon_slot >= 0)
{
if (psAttacker->type == OBJ_DROID)
@ -687,7 +685,7 @@ static void proj_InFlightFunc(PROJECTILE *psProj, bool bIndirect)
// Projectile is missile:
bool bMissile = false;
WEAPON_STATS *psStats;
Vector3uw nextPos;
Vector3i nextPos;
unsigned int targetDistance, currentDistance;
BASE_OBJECT *psTempObj, *closestCollisionObject = NULL;
SPACETIME closestCollisionSpacetime;
@ -896,20 +894,15 @@ static void proj_InFlightFunc(PROJECTILE *psProj, bool bIndirect)
// Actual collision test.
{
// FIXME HACK Needed since we got those ugly Vector3uw floating around in BASE_OBJECT...
Vector3i
posProj = {psProj->pos.x, psProj->pos.y, nextPosZ}, // HACK psProj->pos.z may have been set to 0, since psProj->pos.z can't be negative. So can't use Vector3uw_To3i.
prevPosProj = Vector3uw_To3i(psProj->prevSpacetime.pos),
posTemp = Vector3uw_To3i(psTempObj->pos);
Vector3i diff = Vector3i_Sub(posProj, posTemp);
Vector3i prevDiff = Vector3i_Sub(prevPosProj, posTemp); // HACK Ignore that target might be moving. The projectile is probably moving faster, so it's better than nothing...
unsigned int targetHeight = establishTargetHeight(psTempObj);
unsigned int targetRadius = establishTargetRadius(psTempObj);
int32_t collision = collisionXYZ(prevDiff, diff, targetRadius, targetHeight);
uint32_t collisionTime = psProj->prevSpacetime.time + (psProj->time - psProj->prevSpacetime.time)*collision/1024;
const Vector3i posProj = {psProj->pos.x, psProj->pos.y, nextPosZ}; // HACK psProj->pos.z may have been set to 0, since psProj->pos.z can't be negative.
const Vector3i prevPosProj = psProj->prevSpacetime.pos;
const Vector3i posTemp = psTempObj->pos;
const Vector3i diff = Vector3i_Sub(posProj, posTemp);
const Vector3i prevDiff = Vector3i_Sub(prevPosProj, posTemp); // HACK Ignore that target might be moving. The projectile is probably moving faster, so it's better than nothing...
const unsigned int targetHeight = establishTargetHeight(psTempObj);
const unsigned int targetRadius = establishTargetRadius(psTempObj);
const int32_t collision = collisionXYZ(prevDiff, diff, targetRadius, targetHeight);
const uint32_t collisionTime = psProj->prevSpacetime.time + (psProj->time - psProj->prevSpacetime.time)*collision/1024;
if (collision >= 0 && collisionTime < closestCollisionSpacetime.time)
{
@ -1251,7 +1244,7 @@ static void proj_ImpactFunc( PROJECTILE *psObj )
// Check whether we can hit it and it is in hit radius
if (!((psStats->surfaceToAir == SHOOT_IN_AIR && !bTargetInAir) ||
(psStats->surfaceToAir == SHOOT_ON_GROUND && bTargetInAir)) &&
Vector3i_InSphere(Vector3uw_To3i(psCurrD->pos), Vector3uw_To3i(psObj->pos), psStats->radius))
Vector3i_InSphere(psCurrD->pos, psObj->pos, psStats->radius))
{
int dice = gameRand(100);
if (dice < weaponRadiusHit(psStats, psObj->player))
@ -1299,7 +1292,7 @@ static void proj_ImpactFunc( PROJECTILE *psObj )
if ((BASE_OBJECT *)psCurrS != psObj->psDest)
{
// Check whether it is in hit radius
if (Vector3i_InCircle(Vector3uw_To3i(psCurrS->pos), Vector3uw_To3i(psObj->pos), psStats->radius))
if (Vector3i_InCircle(psCurrS->pos, psObj->pos, psStats->radius))
{
int dice = gameRand(100);
if (dice < weaponRadiusHit(psStats, psObj->player))
@ -1345,7 +1338,7 @@ static void proj_ImpactFunc( PROJECTILE *psObj )
if ((BASE_OBJECT *)psCurrF != psObj->psDest)
{
// Check whether it is in hit radius
if (Vector3i_InCircle(Vector3uw_To3i(psCurrF->pos), Vector3uw_To3i(psObj->pos), psStats->radius))
if (Vector3i_InCircle(psCurrF->pos, psObj->pos, psStats->radius))
{
int dice = gameRand(100);
if (dice < weaponRadiusHit(psStats, psObj->player))

View File

@ -6378,8 +6378,7 @@ BOOL scrFireWeaponAtObj(void)
return false;
}
// FIXME HACK Needed since we got those ugly Vector3uw floating around in BASE_OBJECT...
target = Vector3uw_To3i(psTarget->pos);
target = psTarget->pos;
// send the projectile using the selectedPlayer so that it can always be seen
proj_SendProjectile(&sWeapon, NULL, selectedPlayer, target, psTarget, true, 0);

View File

@ -381,7 +381,7 @@ void revealAll(UBYTE player)
*/
int visibleObject(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget, bool wallsBlock)
{
Vector3i pos, dest, diff;
Vector3i diff;
int range, distSq;
int power;
@ -393,10 +393,7 @@ int visibleObject(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget, bool
return 0;
}
// FIXME HACK Needed since we got those ugly Vector3uw floating around in BASE_OBJECT...
pos = Vector3uw_To3i(psViewer->pos);
dest = Vector3uw_To3i(psTarget->pos);
diff = Vector3i_Sub(dest, pos);
diff = Vector3i_Sub(psViewer->pos, psTarget->pos);
range = objSensorRange(psViewer);
/* Get the sensor Range and power */
@ -482,11 +479,11 @@ int visibleObject(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget, bool
power = adjustPowerByRange(psViewer->pos.x, psViewer->pos.y, psTarget->pos.x, psTarget->pos.y, range, objSensorPower(psViewer));
{
// initialise the callback variables
VisibleObjectHelp_t help = { true, wallsBlock, distSq, pos.z + visObjHeight(psViewer), { map_coord(dest.x), map_coord(dest.y) }, 0, 0, -UBYTE_MAX * GRAD_MUL * ELEVATION_SCALE, 0, { 0, 0 } };
VisibleObjectHelp_t help = { true, wallsBlock, distSq, psViewer->pos.z + visObjHeight(psViewer), { map_coord(psTarget->pos.x), map_coord(psTarget->pos.y) }, 0, 0, -UBYTE_MAX * GRAD_MUL * ELEVATION_SCALE, 0, { 0, 0 } };
int targetGrad, top;
// Cast a ray from the viewer to the target
rayCast(pos, diff, range, rayLOSCallback, &help);
rayCast(psViewer->pos, diff, range, rayLOSCallback, &help);
if (gWall != NULL && gNumWalls != NULL) // Out globals are set
{
@ -495,7 +492,7 @@ int visibleObject(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget, bool
}
// See if the target can be seen
top = dest.z + visObjHeight(psTarget) - help.startHeight;
top = psTarget->pos.z + visObjHeight(psTarget) - help.startHeight;
targetGrad = top * GRAD_MUL / MAX(1, help.lastDist);
if (targetGrad >= help.currGrad)
@ -787,7 +784,7 @@ MAPTILE *psTile;
*/
bool lineOfFire(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget, bool wallsBlock)
{
Vector3i pos, dest, diff;
Vector3i diff;
int range, distSq;
ASSERT(psViewer != NULL, "Invalid shooter pointer!");
@ -797,10 +794,7 @@ bool lineOfFire(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget, bool w
return false;
}
// FIXME HACK Needed since we got those ugly Vector3uw floating around in BASE_OBJECT...
pos = Vector3uw_To3i(psViewer->pos);
dest = Vector3uw_To3i(psTarget->pos);
diff = Vector3i_Sub(dest, pos);
diff = Vector3i_Sub(psViewer->pos, psTarget->pos);
range = objSensorRange(psViewer);
distSq = Vector3i_ScalarP(diff, diff);
@ -812,11 +806,11 @@ bool lineOfFire(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget, bool w
// initialise the callback variables
{
VisibleObjectHelp_t help = { true, wallsBlock, distSq, pos.z + visObjHeight(psViewer), { map_coord(dest.x), map_coord(dest.y) }, 0, 0, -UBYTE_MAX * GRAD_MUL * ELEVATION_SCALE, 0, { 0, 0 } };
VisibleObjectHelp_t help = { true, wallsBlock, distSq, psViewer->pos.z + visObjHeight(psViewer), { map_coord(psTarget->pos.x), map_coord(psTarget->pos.y) }, 0, 0, -UBYTE_MAX * GRAD_MUL * ELEVATION_SCALE, 0, { 0, 0 } };
int targetGrad, top;
// Cast a ray from the viewer to the target
rayCast(pos, diff, range, rayLOSCallback, &help);
rayCast(psViewer->pos, diff, range, rayLOSCallback, &help);
if (gWall != NULL && gNumWalls != NULL) // Out globals are set
{
@ -825,7 +819,7 @@ bool lineOfFire(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget, bool w
}
// See if the target can be seen
top = dest.z + visObjHeight(psTarget) - help.startHeight;
top = psTarget->pos.z + visObjHeight(psTarget) - help.startHeight;
targetGrad = top * GRAD_MUL / MAX(1, help.lastDist);
return targetGrad >= help.currGrad;