diff --git a/binaries/data/mods/official/entities/template_unit_super_cavalry.xml b/binaries/data/mods/official/entities/template_unit_super_cavalry.xml index 037d0e5797..65a800746d 100644 --- a/binaries/data/mods/official/entities/template_unit_super_cavalry.xml +++ b/binaries/data/mods/official/entities/template_unit_super_cavalry.xml @@ -18,6 +18,8 @@ 1 + 1000 + 3 50 0 0.9 diff --git a/source/graphics/Camera.cpp b/source/graphics/Camera.cpp index 9fa5dfade1..1dc5f6e3ee 100644 --- a/source/graphics/Camera.cpp +++ b/source/graphics/Camera.cpp @@ -187,7 +187,7 @@ void CCamera::BuildCameraRay( int px, int py, CVector3D& origin, CVector3D& dir 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; 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 ) { - CHFTracer tracer( g_Game->GetWorld()->GetTerrain() ); int x, z; - + CHFTracer tracer( g_Game->GetWorld()->GetTerrain() ); + int x, z; CVector3D origin, dir, delta, currentTarget; BuildCameraRay( px, py, origin, dir ); diff --git a/source/graphics/Camera.h b/source/graphics/Camera.h index 8e33c7f905..019d9243f5 100644 --- a/source/graphics/Camera.h +++ b/source/graphics/Camera.h @@ -74,7 +74,7 @@ class CCamera // General helpers that seem to fit here // 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) CVector3D GetWorldCoordinates(int px, int py); diff --git a/source/simulation/BaseEntity.cpp b/source/simulation/BaseEntity.cpp index aa798dacdb..baebbae528 100644 --- a/source/simulation/BaseEntity.cpp +++ b/source/simulation/BaseEntity.cpp @@ -79,6 +79,7 @@ CBaseEntity::CBaseEntity( CPlayer* player ) m_corpse = CStrW(); m_foundation = CStrW(); 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). m_speed=0; diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index fd4b8a273a..046607d014 100644 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -41,11 +41,6 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation, cons m_ahead.y = cos( m_orientation.Y ); 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 also be added to BaseEntity.h */ @@ -125,14 +120,6 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation, cons m_actorSelections = actorSelections; 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); for ( int i=0; i( m_position_previous, m_position, relativeoffset ); // 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 ) m_orientation_previous.Y -= 2 * PI; while( m_orientation.Y > m_orientation_previous.Y + PI )