Skip to content

Commit

Permalink
Progressing
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Dec 31, 2023
1 parent 2cb142c commit dbeda82
Show file tree
Hide file tree
Showing 209 changed files with 256,993 additions and 55 deletions.
3 changes: 3 additions & 0 deletions Dependencies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ IncludeDir.libvorbis = "%{wks.location}/Toshi/Vendor/libvorbis/include"
IncludeDir.libtheora = "%{wks.location}/Toshi/Vendor/libtheora/include"
IncludeDir.theoraplay = "%{wks.location}/Toshi/Vendor/theoraplay/include"
IncludeDir.stb = "%{wks.location}/Toshi/Vendor/stb"
IncludeDir.dx8 = "%{wks.location}/Toshi/vendor/DX81/include"
IncludeDir.catch2 = "%{wks.location}/Tools/Vendor/Catch2/include"

LibDir = {}
LibDir.fmod = "%{wks.location}/Toshi/vendor/fmod/lib"
LibDir.bink = "%{wks.location}/Toshi/vendor/bink/lib"
LibDir.dx8 = "%{wks.location}/Toshi/vendor/DX81/lib"
LibDir.catch2 = "%{wks.location}/Tools/Vendor/Catch2/lib"

-- content of these folders should be copied to any client application
Expand All @@ -19,5 +21,6 @@ ClientContentArch = "%{wks.location}Content"

-- modify paths based on architecture
--LibDir.fmod = LibDir.fmod .. "/" .. _OPTIONS["arch"] .. "/"
--LibDir.bink = LibDir.bink .. "/" .. _OPTIONS["arch"] .. "/"
LibDir.catch2 = LibDir.catch2 .. "/" .. _OPTIONS["arch"] .. "/"
ClientContentArch = ClientContentArch .. "/" .. _OPTIONS["arch"] .. "/"
308 changes: 305 additions & 3 deletions Toshi/Include/TKernel/TNodeList.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TOSHI_EXPORT TGenericNodeList
TNode* m_pPrev; // 0x8
};

class Iterator
class TOSHI_EXPORT Iterator
{
public:

Expand Down Expand Up @@ -323,13 +323,315 @@ class TOSHI_EXPORT TGenericNodeList
TINT m_iCount; // 0x10
};

// For the mean time use this until we probably implemented this
template <class T>
class TNodeList : public TGenericNodeList
class TNodeList
{
public:
class TNode
{
public:
friend TNodeList;

public:
TNode()
{
m_Next = this;
m_Prev = this;
m_List = TNULL;
}

TNode(const TNode& node)
{
m_Next = node.m_Next;
m_Prev = node.m_Prev;
m_List = node.m_List;
}

void Remove()
{
m_List->Remove(*this);
}

T* Next() const
{
return m_Next->As<T>();
}

T* Prev() const
{
return m_Prev->As<T>();
}

TBOOL IsLinked() const
{
return m_List != TNULL;
}

void SetList(TNodeList* list)
{
m_List = list;
}

TNodeList* GetList() const
{
return m_List;
}

template<class T>
T* As()
{
return static_cast<T*>(this);
}

TNode& operator=(const TNode& node)
{
m_Next = node.m_Next;
m_Prev = node.m_Prev;
m_List = node.m_List;
return *this;
}

protected:
TNodeList* m_List;
TNode* m_Next;
TNode* m_Prev;
};

class Iterator
{
public:

Iterator()
{
m_pPtr = TNULL;
}

Iterator(TNode* a_pNode)
{
m_pPtr = static_cast<T*>(a_pNode);
}

Iterator(T* a_pNode)
{
m_pPtr = a_pNode;
}

Iterator(const Iterator& a_rIterator)
{
m_pPtr = a_rIterator.m_pPtr;
}

~Iterator() = default;

TBOOL operator!() { return IsNull(); }
TBOOL operator!=(Iterator& a_rIterator) { return m_pPtr != a_rIterator.m_pPtr; }

T& operator*() const
{
TASSERT(m_pPtr != TNULL);
return *m_pPtr;
}

Iterator& operator++()
{
TASSERT(m_pPtr != TNULL);
m_pPtr = m_pPtr->Next();
return *this;
}

Iterator operator++(int)
{
TASSERT(m_pPtr != TNULL);
Iterator old = m_pPtr;
m_pPtr = m_pPtr->Next();
return old;
}

Iterator operator--()
{
TASSERT(m_pPtr != TNULL);
m_pPtr = m_pPtr->Prev();
return *this;
}

T* operator->() const
{
return m_pPtr;
}

Iterator& operator=(const Iterator& a_rIterator)
{
m_pPtr = a_rIterator.m_pPtr;
return *this;
}

TBOOL operator==(Iterator& a_rIterator) const
{
return m_pPtr == a_rIterator.m_pPtr;
}

operator TNode* () const
{
return m_pPtr;
}

operator T* () const
{
return m_pPtr;
}

TBOOL IsNull() { return m_pPtr == TNULL; }

private:
T* m_pPtr;
};

public:
TNodeList()
{
m_Count = 0;
}

TNodeList() { }
~TNodeList()
{
DeleteAll();
}

void InsertAfter(TNode& insertAfter, TNode& newNode)
{
TASSERT(!newNode.IsLinked());
newNode.SetList(this);
newNode.m_Next = insertAfter.m_Next;
newNode.m_Prev = &insertAfter;
insertAfter.m_Next->m_Prev = &newNode;
insertAfter.m_Next = &newNode;
m_Count++;
}

void InsertBefore(TNode& insertBefore, TNode& newNode)
{
TASSERT(!newNode.IsLinked());
newNode.SetList(this);
newNode.m_Next = &insertBefore;
newNode.m_Prev = insertBefore.m_Prev;
insertBefore.m_Prev->m_Next = &newNode;
insertBefore.m_Prev = &newNode;
m_Count++;
}

TNode* Remove(TNode& rNode)
{
TASSERT(rNode.GetList() == this);
rNode.SetList(TNULL);
rNode.m_Prev->m_Next = rNode.m_Next;
rNode.m_Next->m_Prev = rNode.m_Prev;
rNode.m_Next = &rNode;
rNode.m_Prev = &rNode;
m_Count--;
TASSERT(rNode.IsLinked() == TFALSE);
return &rNode;
}

void RemoveAll()
{
while (!IsEmpty())
return Remove(*m_Head.Next());
}

TNode* RemoveHead()
{
if (!IsEmpty())
{
return Remove(*m_Head.Next());
}

return TNULL;
}

TNode* RemoveTail()
{
if (!IsEmpty())
{
return Remove(*m_Head.Prev());
}

return TNULL;
}

void DeleteHead()
{
Delete(Head());
}

void DeleteTail()
{
Delete(Tail());
}

void DeleteAll()
{
while (!IsEmpty())
{
Delete(*m_Head.Next());
}
}

void Delete(TNode& node)
{
Remove(node);

delete& node;
}

void InsertHead(TNode& node)
{
InsertAfter(m_Head, node);
}

void InsertTail(TNode& node)
{
InsertBefore(m_Head, node);
}

TBOOL IsEmpty() const
{
return m_Head.Next() == &m_Head;
}

TBOOL IsValid(const TNode* node) const
{
return node != TNULL && node->m_List == this;
}

size_t Count() const
{
return m_Count;
}

Iterator Begin() const
{
return m_Head.m_Next;
}

Iterator Head() const
{
return m_Head.m_Next;
}

Iterator Tail() const
{
return m_Head.m_Prev;
}

Iterator End()
{
return &m_Head;
}

protected:
TNode m_Head;
size_t m_Count;
};

TOSHI_NAMESPACE_END
10 changes: 5 additions & 5 deletions Toshi/Include/TKernel/TTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TOSHI_EXPORT TTask : public TObject, public TNodeTree<TTask>::TNode

TTask()
{
m_iState = 0;
m_Flags = 0;
}

virtual TBOOL Create();
Expand All @@ -40,14 +40,14 @@ class TOSHI_EXPORT TTask : public TObject, public TNodeTree<TTask>::TNode
void Activate(TBOOL a_bActivate);
void DestroyTask();

TBOOL IsCreated() const { return HASFLAG(m_iState & State_Created); }
TBOOL IsActive() const { return HASFLAG(m_iState & State_Active); }
TBOOL IsDying() const { return HASFLAG(m_iState & State_Dying); }
TBOOL IsCreated() const { return HASFLAG(m_Flags & State_Created); }
TBOOL IsActive() const { return HASFLAG(m_Flags & State_Active); }
TBOOL IsDying() const { return HASFLAG(m_Flags & State_Dying); }

TScheduler* GetScheduler();

private:
TINT m_iState;
TINT m_Flags;
TScheduler* m_pScheduler; // 0x20
};

Expand Down
Loading

0 comments on commit dbeda82

Please sign in to comment.