diff options
| -rw-r--r-- | src/game/client/components/items.cpp | 27 | ||||
| -rw-r--r-- | src/game/client/components/items.h | 11 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 27 | ||||
| -rw-r--r-- | src/game/client/gameclient.h | 1 |
4 files changed, 43 insertions, 23 deletions
diff --git a/src/game/client/components/items.cpp b/src/game/client/components/items.cpp index 526c94d6..db0b8abd 100644 --- a/src/game/client/components/items.cpp +++ b/src/game/client/components/items.cpp @@ -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++; + } } diff --git a/src/game/client/components/items.h b/src/game/client/components/items.h index 17702394..c366b8d9 100644 --- a/src/game/client/components/items.h +++ b/src/game/client/components/items.h @@ -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 diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index e5b5e298..28fdb31e 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -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) { diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index 5a045708..7aa02ace 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -240,6 +240,7 @@ public: class CMapImages *m_pMapimages; class CVoting *m_pVoting; class CScoreboard *m_pScoreboard; + class CItems *m_pItems; }; |