mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05:00
Fix linked list
This commit is contained in:
parent
4bcf3ba89a
commit
2b51f5f187
2 changed files with 48 additions and 8 deletions
|
@ -13,6 +13,14 @@ public:
|
|||
m_pNext = pAttach;
|
||||
}
|
||||
|
||||
inline void InsertBefore(CLinkSA<T>* pAttach) {
|
||||
pAttach->m_pPrev = m_pPrev;
|
||||
m_pPrev->m_pNext = pAttach;
|
||||
|
||||
pAttach->m_pNext = this;
|
||||
m_pPrev = pAttach;
|
||||
}
|
||||
|
||||
inline void Remove(void) {
|
||||
m_pNext->m_pPrev = m_pPrev;
|
||||
m_pPrev->m_pNext = m_pNext;
|
||||
|
@ -38,7 +46,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void Init(int nNumLinks) {
|
||||
void Init(size_t nNumLinks) {
|
||||
m_plnLinks = new CLinkSA<T>[nNumLinks];
|
||||
|
||||
m_lnListHead.m_pNext = &m_lnListTail;
|
||||
|
@ -47,8 +55,8 @@ public:
|
|||
m_lnFreeListHead.m_pNext = &m_lnFreeListTail;
|
||||
m_lnFreeListTail.m_pPrev = &m_lnFreeListHead;
|
||||
|
||||
for(int i = nNumLinks - 1; i >= 0; i--) {
|
||||
m_lnFreeListHead.Insert(&m_plnLinks[i]);
|
||||
for(size_t i = nNumLinks; i > 0; --i) {
|
||||
m_lnFreeListHead.Insert(&m_plnLinks[i - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,9 +103,28 @@ public:
|
|||
return pLink;
|
||||
}
|
||||
|
||||
CLinkSA<T>* InsertFront(const T& pItem) {
|
||||
return Insert(pItem);
|
||||
}
|
||||
|
||||
CLinkSA<T>* InsertBack(const T& pItem) {
|
||||
CLinkSA<T>* pLink = m_lnFreeListHead.m_pNext;
|
||||
|
||||
if(pLink == &m_lnFreeListTail) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pLink->m_pItem = pItem;
|
||||
|
||||
pLink->Remove();
|
||||
m_lnListTail.InsertBefore(pLink);
|
||||
|
||||
return pLink;
|
||||
}
|
||||
|
||||
void Clear(void) {
|
||||
while(m_lnListHead.m_pNext != &m_lnListTail) {
|
||||
m_lnListHead.m_pNext->Remove();
|
||||
Remove( m_lnListHead.m_pNext );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,18 +134,31 @@ public:
|
|||
}
|
||||
|
||||
CLinkSA<T>* Next(CLinkSA<T>* pCurrent) {
|
||||
if(pCurrent == 0) {
|
||||
if(pCurrent == nullptr) {
|
||||
pCurrent = &m_lnListHead;
|
||||
}
|
||||
|
||||
if(pCurrent->m_pNext == &m_lnListTail) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
return pCurrent->m_pNext;
|
||||
}
|
||||
}
|
||||
|
||||
CLinkSA<T>* Prev(CLinkSA<T>* pCurrent) {
|
||||
if(pCurrent == nullptr) {
|
||||
pCurrent = &m_lnListTail;
|
||||
}
|
||||
|
||||
if(pCurrent->m_pPrev == &m_lnListHead) {
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
return pCurrent->m_pPrev;
|
||||
}
|
||||
}
|
||||
|
||||
CLinkSA<T> m_lnListHead; // 0-12
|
||||
//head of the list of active links
|
||||
CLinkSA<T> m_lnListTail; // 12-24
|
||||
|
|
|
@ -401,7 +401,7 @@ void RenderVehicleHiDetailAlphaCB_HunterDoor(RpAtomic* pAtomic)
|
|||
NewObject.fCompareValue = -std::numeric_limits<float>::infinity();
|
||||
NewObject.pAtomic = pAtomic;
|
||||
|
||||
m_alphaList.InsertSorted(NewObject);
|
||||
m_alphaList.InsertFront(NewObject);
|
||||
}
|
||||
|
||||
template <RpAtomic* renderer(RpAtomic*)>
|
||||
|
@ -431,7 +431,7 @@ void RenderWeaponPedsForPC()
|
|||
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(TRUE));
|
||||
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
|
||||
|
||||
for ( auto it = ms_weaponPedsForPC.m_lnListHead.m_pNext; it != &ms_weaponPedsForPC.m_lnListTail; it = it->m_pNext )
|
||||
for ( auto it = ms_weaponPedsForPC.Next( nullptr ); it != nullptr; it = ms_weaponPedsForPC.Next( it ) )
|
||||
{
|
||||
it->V()->SetupLighting();
|
||||
it->V()->RenderWeapon(true, false);
|
||||
|
|
Loading…
Reference in a new issue