From 91070f80d01d6937748634369c81a93280da1e8d Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 2 Mar 2017 21:47:09 +0100 Subject: [PATCH] refactor linked lists --- SilentPatchSA/LinkListSA.h | 19 ++++++++++++------- SilentPatchSA/SilentPatchSA.cpp | 7 ++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/SilentPatchSA/LinkListSA.h b/SilentPatchSA/LinkListSA.h index 65f859f..6ef2e9f 100644 --- a/SilentPatchSA/LinkListSA.h +++ b/SilentPatchSA/LinkListSA.h @@ -4,6 +4,9 @@ template class CLinkSA { + template + friend class CLinkListSA; + public: inline void Insert(CLinkSA* pAttach) { pAttach->m_pNext = m_pNext; @@ -26,10 +29,15 @@ public: m_pPrev->m_pNext = m_pNext; } - inline T& V(void) { + inline T& operator*(void) { return m_pItem; } + inline const T& operator*(void) const { + return m_pItem; + } + +private: T m_pItem; // 0-4 // an item CLinkSA* m_pPrev; // 4-8 @@ -141,9 +149,7 @@ public: if(pCurrent->m_pNext == &m_lnListTail) { return nullptr; } - else { - return pCurrent->m_pNext; - } + return pCurrent->m_pNext; } CLinkSA* Prev(CLinkSA* pCurrent) { @@ -154,11 +160,10 @@ public: if(pCurrent->m_pPrev == &m_lnListHead) { return nullptr; } - else { - return pCurrent->m_pPrev; - } + return pCurrent->m_pPrev; } +private: CLinkSA m_lnListHead; // 0-12 //head of the list of active links CLinkSA m_lnListTail; // 12-24 diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index d6bfae0..eb01ec6 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -432,9 +432,10 @@ void RenderWeaponPedsForPC() for ( auto it = ms_weaponPedsForPC.Next( nullptr ); it != nullptr; it = ms_weaponPedsForPC.Next( it ) ) { - it->V()->SetupLighting(); - it->V()->RenderWeapon(true, false); - it->V()->RemoveLighting(); + CPed* ped = **it; + ped->SetupLighting(); + ped->RenderWeapon(true, false); + ped->RemoveLighting(); } }