mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge branch 'DDRace64' of github.com:def-/ddnet into DDRace64
This commit is contained in:
commit
c15fc5bc19
|
@ -111,6 +111,7 @@ public:
|
|||
|
||||
// input
|
||||
virtual int *GetInput(int Tick) = 0;
|
||||
virtual bool InputExists(int Tick) = 0;
|
||||
|
||||
// remote console
|
||||
virtual void RconAuth(const char *pUsername, const char *pPassword) = 0;
|
||||
|
|
|
@ -595,6 +595,14 @@ int *CClient::GetInput(int Tick)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool CClient::InputExists(int Tick)
|
||||
{
|
||||
for(int i = 0; i < 200; i++)
|
||||
if(m_aInputs[g_Config.m_ClDummy][i].m_Tick == Tick)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------ state handling -----
|
||||
void CClient::SetState(int s)
|
||||
{
|
||||
|
|
|
@ -236,6 +236,7 @@ public:
|
|||
|
||||
// TODO: OPT: do this alot smarter!
|
||||
virtual int *GetInput(int Tick);
|
||||
virtual bool InputExists(int Tick);
|
||||
|
||||
const char *LatestVersion();
|
||||
void VersionUpdate();
|
||||
|
|
|
@ -625,6 +625,18 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy)
|
|||
return;
|
||||
|
||||
g_GameClient.m_pItems->AddExtraProjectile(&Proj);
|
||||
|
||||
if(!HasExtraInfo(&Proj))
|
||||
{
|
||||
CLocalProjectile NewProj;
|
||||
NewProj.Init(this, 0, Collision(), &Proj);
|
||||
NewProj.m_Owner = m_Snap.m_LocalClientID;
|
||||
CLocalProjectile *LocalProj = FindLocalProjectile(&NewProj);
|
||||
if(LocalProj)
|
||||
NewProj = *LocalProj;
|
||||
else
|
||||
m_aLocalProjectiles[NewProj.m_StartTick % 64] = NewProj;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -1229,17 +1241,21 @@ void CGameClient::OnPredict()
|
|||
const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, Index, &Item);
|
||||
if(Item.m_Type == NETOBJTYPE_PROJECTILE)
|
||||
{
|
||||
if(((const CNetObj_Projectile*)pData)->m_Type == WEAPON_GRENADE)
|
||||
{
|
||||
TempProjectiles[NumProjectiles].Init(this, &World, Collision(), (const CNetObj_Projectile *)pData);
|
||||
|
||||
int Index = TempProjectiles[NumProjectiles].m_StartTick % 64;
|
||||
if(m_aLocalProjectiles[Index].m_Active)
|
||||
if(m_aLocalProjectiles[Index].m_StartTick == TempProjectiles[NumProjectiles].m_StartTick)
|
||||
if(distance(m_aLocalProjectiles[Index].m_Pos, TempProjectiles[NumProjectiles].m_Pos) < 3)
|
||||
TempProjectiles[NumProjectiles] = m_aLocalProjectiles[Index];
|
||||
NumProjectiles++;
|
||||
}
|
||||
CNetObj_Projectile* pProj = (CNetObj_Projectile*) pData;
|
||||
if(pProj->m_Type == WEAPON_GRENADE || (pProj->m_Type == WEAPON_SHOTGUN && HasExtraInfo(pProj)))
|
||||
{
|
||||
CLocalProjectile NewProj;
|
||||
NewProj.Init(this, &World, Collision(), pProj);
|
||||
if(!NewProj.m_ExtraInfo)
|
||||
{
|
||||
CLocalProjectile *LocalProj = FindLocalProjectile(&NewProj);
|
||||
if(LocalProj)
|
||||
NewProj = *LocalProj;
|
||||
}
|
||||
NewProj.m_pWorld = &World;
|
||||
TempProjectiles[NumProjectiles] = NewProj;
|
||||
NumProjectiles++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1323,7 +1339,15 @@ void CGameClient::OnPredict()
|
|||
vec2 Pos = Local->m_Pos;
|
||||
vec2 ProjStartPos = Pos + Direction * ProximityRadius * 0.75f;
|
||||
|
||||
int ExpectedStartTick = Tick-1;
|
||||
ReloadTimer = g_pData->m_Weapons.m_aId[Local->m_ActiveWeapon].m_Firedelay * SERVER_TICK_SPEED / 1000;
|
||||
|
||||
bool DirectInput = Client()->InputExists(Tick);
|
||||
if(!DirectInput)
|
||||
{
|
||||
ReloadTimer++;
|
||||
ExpectedStartTick++;
|
||||
}
|
||||
switch(Local->m_ActiveWeapon)
|
||||
{
|
||||
case WEAPON_GRENADE:
|
||||
|
@ -1334,13 +1358,16 @@ void CGameClient::OnPredict()
|
|||
this, &World, Collision(),
|
||||
Direction, //StartDir
|
||||
ProjStartPos, //StartPos
|
||||
Tick-1, //StartTick
|
||||
ExpectedStartTick, //StartTick
|
||||
WEAPON_GRENADE, //Type
|
||||
m_Snap.m_LocalClientID, //Owner
|
||||
WEAPON_GRENADE, //Weapon
|
||||
1000, //LifeSpan
|
||||
1, 0, 0, 1); //Explosive, Bouncing, Freeze, ExtraInfo
|
||||
m_aLocalProjectiles[(Tick-1)%64] = TempProjectiles[NumProjectiles];
|
||||
|
||||
m_aLocalProjectiles[ExpectedStartTick%64] = TempProjectiles[NumProjectiles];
|
||||
m_aLocalProjectiles[ExpectedStartTick%64].m_pWorld = 0;
|
||||
|
||||
NumProjectiles++;
|
||||
} break;
|
||||
|
||||
|
@ -1821,6 +1848,8 @@ void CLocalProjectile::Tick(int CurrentTick, int GameTickSpeed, int LocalClientI
|
|||
{
|
||||
if(!m_pWorld)
|
||||
return;
|
||||
if(CurrentTick <= m_StartTick)
|
||||
return;
|
||||
float Pt = (CurrentTick-m_StartTick-1)/(float)GameTickSpeed;
|
||||
float Ct = (CurrentTick-m_StartTick)/(float)GameTickSpeed;
|
||||
|
||||
|
@ -1912,3 +1941,13 @@ void CLocalProjectile::CreateExplosion(vec2 Pos, int LocalClientID)
|
|||
m_pWorld->m_apCharacters[c]->TakeDamage(ForceDir*Dmg*2);
|
||||
}
|
||||
}
|
||||
|
||||
CLocalProjectile *CGameClient::FindLocalProjectile(CLocalProjectile *pProj)
|
||||
{
|
||||
int Index = pProj->m_StartTick % 64;
|
||||
if(m_aLocalProjectiles[Index].m_Active)
|
||||
if(m_aLocalProjectiles[Index].m_StartTick == pProj->m_StartTick)
|
||||
if(distance(m_aLocalProjectiles[Index].m_Pos, pProj->m_Pos) < 3)
|
||||
return &m_aLocalProjectiles[Index];
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -319,6 +319,7 @@ public:
|
|||
int IntersectCharacter(vec2 OldPos, vec2 NewPos, float Radius, vec2* NewPos2, int ownID, CWorldCore *World);
|
||||
|
||||
class CLocalProjectile m_aLocalProjectiles[64];
|
||||
CLocalProjectile *FindLocalProjectile(CLocalProjectile *pProj);
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in a new issue