From 88a1565d752619edbbbe59bb3c82e2da6299b54b Mon Sep 17 00:00:00 2001 From: nuborn Date: Tue, 2 Dec 2014 01:08:52 +0100 Subject: [PATCH] make the prediction compatible with very large maps --- src/game/gamecore.cpp | 4 ++-- src/game/server/entities/projectile.cpp | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index 6589fe28a..c7520c872 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -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); diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp index 382e87bd9..a52c0575b 100644 --- a/src/game/server/entities/projectile.cpp +++ b/src/game/server/entities/projectile.cpp @@ -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;