1
0
forked from 0ad/0ad

# Fixed infinite loop.

Also fixed sectorDivs so it's always initialised, since the complaints
were annoying.
Camera: Added a const.
Super cavalry: Added required(?) aura attributes.

This was SVN commit r3906.
This commit is contained in:
Ykkrosh 2006-05-29 03:28:54 +00:00
parent 1a8cb85e08
commit 03a08e00a5
5 changed files with 12 additions and 17 deletions

View File

@ -18,6 +18,8 @@
<Auras> <Auras>
<Trample> <Trample>
<Radius>1</Radius> <Radius>1</Radius>
<Speed>1000</Speed>
<Duration>3</Duration>
<Damage>50</Damage> <Damage>50</Damage>
<Crush>0</Crush> <Crush>0</Crush>
<Hack>0.9</Hack> <Hack>0.9</Hack>

View File

@ -187,7 +187,7 @@ void CCamera::BuildCameraRay( int px, int py, CVector3D& origin, CVector3D& dir
dir.Normalize(); dir.Normalize();
} }
void CCamera::GetScreenCoordinates( const CVector3D& world, float& x, float& y ) void CCamera::GetScreenCoordinates( const CVector3D& world, float& x, float& y ) const
{ {
CMatrix3D transform; CMatrix3D transform;
m_Orientation.GetInverse( transform ); m_Orientation.GetInverse( transform );
@ -203,8 +203,8 @@ void CCamera::GetScreenCoordinates( const CVector3D& world, float& x, float& y )
CVector3D CCamera::GetWorldCoordinates( int px, int py ) CVector3D CCamera::GetWorldCoordinates( int px, int py )
{ {
CHFTracer tracer( g_Game->GetWorld()->GetTerrain() ); int x, z; CHFTracer tracer( g_Game->GetWorld()->GetTerrain() );
int x, z;
CVector3D origin, dir, delta, currentTarget; CVector3D origin, dir, delta, currentTarget;
BuildCameraRay( px, py, origin, dir ); BuildCameraRay( px, py, origin, dir );

View File

@ -74,7 +74,7 @@ class CCamera
// General helpers that seem to fit here // General helpers that seem to fit here
// Get the screen-space coordinates corresponding to a given world-space position // Get the screen-space coordinates corresponding to a given world-space position
void GetScreenCoordinates(const CVector3D& world, float& x, float& y); void GetScreenCoordinates(const CVector3D& world, float& x, float& y) const;
// Get the point on the terrain corresponding to pixel (px,py) (or the mouse coordinates) // Get the point on the terrain corresponding to pixel (px,py) (or the mouse coordinates)
CVector3D GetWorldCoordinates(int px, int py); CVector3D GetWorldCoordinates(int px, int py);

View File

@ -79,6 +79,7 @@ CBaseEntity::CBaseEntity( CPlayer* player )
m_corpse = CStrW(); m_corpse = CStrW();
m_foundation = CStrW(); m_foundation = CStrW();
m_passThroughAllies = false; m_passThroughAllies = false;
m_sectorDivs = 4;
// Sentinel values for stamina and health (so scripts can check if an entity has no stamina or no HP). // Sentinel values for stamina and health (so scripts can check if an entity has no stamina or no HP).
m_speed=0; m_speed=0;

View File

@ -41,11 +41,6 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation, cons
m_ahead.y = cos( m_orientation.Y ); m_ahead.y = cos( m_orientation.Y );
m_player = 0; m_player = 0;
// set sane default in case someone forgets to add this to the entity's
// XML file, which is prone to happen. (prevents crash below when
// using this value to resize a vector)
const int sane_sectordivs_default = 4;
/* Anything added to this list MUST be added to BaseEntity.cpp (and variables used should /* Anything added to this list MUST be added to BaseEntity.cpp (and variables used should
also be added to BaseEntity.h */ also be added to BaseEntity.h */
@ -125,14 +120,6 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation, cons
m_actorSelections = actorSelections; m_actorSelections = actorSelections;
loadBase(); loadBase();
// this has been the cause of several crashes (due to not being
// specified in the XML file), so in addition to the above default,
// we'll sanity check its value.
if(!(0 <= m_sectorDivs && m_sectorDivs < 360))
{
debug_warn("invalid entity flank_penalty.sectors value");
m_sectorDivs = sane_sectordivs_default;
}
m_sectorValues.resize(m_sectorDivs); m_sectorValues.resize(m_sectorDivs);
for ( int i=0; i<m_sectorDivs; ++i ) for ( int i=0; i<m_sectorDivs; ++i )
m_sectorValues[i] = false; m_sectorValues[i] = false;
@ -889,6 +876,11 @@ void CEntity::interpolate( float relativeoffset )
m_graphics_position = Interpolate<CVector3D>( m_position_previous, m_position, relativeoffset ); m_graphics_position = Interpolate<CVector3D>( m_position_previous, m_position, relativeoffset );
// Avoid wraparound glitches for interpolating angles. // Avoid wraparound glitches for interpolating angles.
m_orientation.X = fmodf(m_orientation.X, 2*PI); // (ensure the following loops can't take forever)
m_orientation.Y = fmodf(m_orientation.Y, 2*PI);
m_orientation.Z = fmodf(m_orientation.Z, 2*PI);
while( m_orientation.Y < m_orientation_previous.Y - PI ) while( m_orientation.Y < m_orientation_previous.Y - PI )
m_orientation_previous.Y -= 2 * PI; m_orientation_previous.Y -= 2 * PI;
while( m_orientation.Y > m_orientation_previous.Y + PI ) while( m_orientation.Y > m_orientation_previous.Y + PI )