reimplemented extra projectiles

This commit is contained in:
Choupom 2011-04-03 10:11:23 +02:00 committed by oy
parent 7a772f4e20
commit 733f0b3390
4 changed files with 43 additions and 23 deletions

View file

@ -15,6 +15,11 @@
#include "items.h"
void CItems::OnReset()
{
ExtraProjectilesNum = 0;
}
void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)
{
@ -302,15 +307,23 @@ void CItems::OnRender()
}
// render extra projectiles
/*
for(int i = 0; i < extraproj_num; i++)
for(int i = 0; i < ExtraProjectilesNum; i++)
{
if(extraproj_projectiles[i].start_tick < Client()->GameTick())
if(aExtraProjectiles[i].m_StartTick < Client()->GameTick())
{
extraproj_projectiles[i] = extraproj_projectiles[extraproj_num-1];
extraproj_num--;
aExtraProjectiles[i] = aExtraProjectiles[ExtraProjectilesNum-1];
ExtraProjectilesNum--;
}
else
render_projectile(&extraproj_projectiles[i], 0);
}*/
RenderProjectile(&aExtraProjectiles[i], 0);
}
}
void CItems::AddExtraProjectile(CNetObj_Projectile *pProj)
{
if(ExtraProjectilesNum != MAX_EXTRA_PROJECTILES)
{
aExtraProjectiles[ExtraProjectilesNum] = *pProj;
ExtraProjectilesNum++;
}
}

View file

@ -6,13 +6,24 @@
class CItems : public CComponent
{
enum
{
MAX_EXTRA_PROJECTILES=32,
};
CNetObj_Projectile aExtraProjectiles[MAX_EXTRA_PROJECTILES];
int ExtraProjectilesNum;
void RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID);
void RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCurrent);
void RenderFlag(const CNetObj_Flag *pPrev, const CNetObj_Flag *pCurrent, const CNetObj_GameData *pPrevGameData, const CNetObj_GameData *pCurGameData);
void RenderLaser(const struct CNetObj_Laser *pCurrent);
public:
virtual void OnReset();
virtual void OnRender();
void AddExtraProjectile(CNetObj_Projectile *pProj);
};
#endif

View file

@ -136,6 +136,7 @@ void CGameClient::OnConsoleInit()
m_pMapimages = &::gs_MapImages;
m_pVoting = &::gs_Voting;
m_pScoreboard = &::gs_Scoreboard;
m_pItems = &::gs_Items;
// make a list of all the systems, make sure to add them in the corrent render order
m_All.Add(m_pSkins);
@ -152,7 +153,7 @@ void CGameClient::OnConsoleInit()
m_All.Add(&gs_MapLayersBackGround); // first to render
m_All.Add(&m_pParticles->m_RenderTrail);
m_All.Add(&gs_Items);
m_All.Add(m_pItems);
m_All.Add(&gs_Players);
m_All.Add(&gs_MapLayersForeGround);
m_All.Add(&m_pParticles->m_RenderExplosions);
@ -477,30 +478,24 @@ void CGameClient::OnRelease()
void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
{
// special messages
if(MsgId == NETMSGTYPE_SV_EXTRAPROJECTILE)
{
/*
int num = msg_unpack_int();
int Num = pUnpacker->GetInt();
for(int k = 0; k < num; k++)
for(int k = 0; k < Num; k++)
{
NETOBJ_PROJECTILE proj;
for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
((int *)&proj)[i] = msg_unpack_int();
CNetObj_Projectile Proj;
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
((int *)&Proj)[i] = pUnpacker->GetInt();
if(msg_unpack_error())
if(pUnpacker->Error())
return;
if(extraproj_num != MAX_EXTRA_PROJECTILES)
{
extraproj_projectiles[extraproj_num] = proj;
extraproj_num++;
}
g_GameClient.m_pItems->AddExtraProjectile(&Proj);
}
return;*/
return;
}
else if(MsgId == NETMSGTYPE_SV_TUNEPARAMS)
{

View file

@ -240,6 +240,7 @@ public:
class CMapImages *m_pMapimages;
class CVoting *m_pVoting;
class CScoreboard *m_pScoreboard;
class CItems *m_pItems;
};