make the prediction compatible with very large maps

This commit is contained in:
nuborn 2014-12-02 01:08:52 +01:00
parent bb9c699f35
commit 88a1565d75
2 changed files with 11 additions and 4 deletions

View file

@ -743,8 +743,8 @@ void ExtractInfo(const CNetObj_Projectile *pProj, vec2 *StartPos, vec2 *StartVel
}
else
{
StartPos->x = pProj->m_X/1000.0f;
StartPos->y = pProj->m_Y/1000.0f;
StartPos->x = pProj->m_X/100.0f;
StartPos->y = pProj->m_Y/100.0f;
float Angle = pProj->m_VelX/1000000.0f;
StartVel->x = sin(-Angle);
StartVel->y = cos(-Angle);

View file

@ -275,6 +275,13 @@ void CProjectile::SetBouncing(int Value)
void CProjectile::FillExtraInfo(CNetObj_Projectile *pProj)
{
const int MaxPos = 0x7fffffff/100;
if(abs(m_Pos.y)+1 >= MaxPos || abs(m_Pos.x)+1 >= MaxPos)
{
//If the modified data would be too large to fit in an integer, send normal data instead
FillInfo(pProj);
return;
}
//Send additional/modified info, by modifiying the fields of the netobj
float Angle = -atan2f(m_Direction.x, m_Direction.y);
@ -289,8 +296,8 @@ void CProjectile::FillExtraInfo(CNetObj_Projectile *pProj)
if(m_Freeze)
Data |= 1<<13;
pProj->m_X = (int)(m_Pos.x * 1000.0f);
pProj->m_Y = (int)(m_Pos.y * 1000.0f);
pProj->m_X = (int)(m_Pos.x * 100.0f);
pProj->m_Y = (int)(m_Pos.y * 100.0f);
pProj->m_VelX = (int)(Angle * 1000000.0f);
pProj->m_VelY = Data;
pProj->m_StartTick = m_StartTick;