mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
make the prediction compatible with very large maps
This commit is contained in:
parent
bb9c699f35
commit
88a1565d75
|
@ -743,8 +743,8 @@ void ExtractInfo(const CNetObj_Projectile *pProj, vec2 *StartPos, vec2 *StartVel
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StartPos->x = pProj->m_X/1000.0f;
|
StartPos->x = pProj->m_X/100.0f;
|
||||||
StartPos->y = pProj->m_Y/1000.0f;
|
StartPos->y = pProj->m_Y/100.0f;
|
||||||
float Angle = pProj->m_VelX/1000000.0f;
|
float Angle = pProj->m_VelX/1000000.0f;
|
||||||
StartVel->x = sin(-Angle);
|
StartVel->x = sin(-Angle);
|
||||||
StartVel->y = cos(-Angle);
|
StartVel->y = cos(-Angle);
|
||||||
|
|
|
@ -275,6 +275,13 @@ void CProjectile::SetBouncing(int Value)
|
||||||
|
|
||||||
void CProjectile::FillExtraInfo(CNetObj_Projectile *pProj)
|
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
|
//Send additional/modified info, by modifiying the fields of the netobj
|
||||||
float Angle = -atan2f(m_Direction.x, m_Direction.y);
|
float Angle = -atan2f(m_Direction.x, m_Direction.y);
|
||||||
|
|
||||||
|
@ -289,8 +296,8 @@ void CProjectile::FillExtraInfo(CNetObj_Projectile *pProj)
|
||||||
if(m_Freeze)
|
if(m_Freeze)
|
||||||
Data |= 1<<13;
|
Data |= 1<<13;
|
||||||
|
|
||||||
pProj->m_X = (int)(m_Pos.x * 1000.0f);
|
pProj->m_X = (int)(m_Pos.x * 100.0f);
|
||||||
pProj->m_Y = (int)(m_Pos.y * 1000.0f);
|
pProj->m_Y = (int)(m_Pos.y * 100.0f);
|
||||||
pProj->m_VelX = (int)(Angle * 1000000.0f);
|
pProj->m_VelX = (int)(Angle * 1000000.0f);
|
||||||
pProj->m_VelY = Data;
|
pProj->m_VelY = Data;
|
||||||
pProj->m_StartTick = m_StartTick;
|
pProj->m_StartTick = m_StartTick;
|
||||||
|
|
Loading…
Reference in a new issue