Skip to content

Commit

Permalink
GetStatSize
Browse files Browse the repository at this point in the history
  • Loading branch information
ZippeyKeys12 committed Sep 14, 2018
1 parent 1c3d4b4 commit 3ba1146
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
41 changes: 41 additions & 0 deletions src/dthinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,29 @@ bool FThinkerList::IsEmpty() const
return Sentinel == NULL || Sentinel->NextThinker == NULL;
}


int FThinkerList::Length() const
{
int i = 0;

if (! (this->IsEmpty ()))
{
DThinker *node = this->GetHead();

if (node == NULL)
{
return 0;
}

while (node != this->Sentinel)
{
i++;
node = node->NextThinker;
}
}

return i;
}
//==========================================================================
//
//
Expand Down Expand Up @@ -741,6 +764,24 @@ int DThinker::ProfileThinkers(FThinkerList *list, FThinkerList *dest)
//
//==========================================================================

int DThinker::StatSize(int statnum)
{
return DThinker::FreshThinkers[statnum].Length() + DThinker::Thinkers[statnum].Length();
}

DEFINE_ACTION_FUNCTION(DThinker, GetStatSize)
{
PARAM_PROLOGUE;
PARAM_INT(statnum);
ACTION_RETURN_INT(DThinker::StatSize(statnum));
}

//==========================================================================
//
//
//
//==========================================================================

void DThinker::Tick ()
{
}
Expand Down
2 changes: 2 additions & 0 deletions src/dthinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct FThinkerList
DThinker *GetHead() const;
DThinker *GetTail() const;
bool IsEmpty() const;
int Length() const;

DThinker *Sentinel;
};
Expand Down Expand Up @@ -87,6 +88,7 @@ class DThinker : public DObject
}
static void SerializeThinkers(FSerializer &arc, bool keepPlayers);
static void MarkRoots();
static int StatSize(int statnum);

static DThinker *FirstThinker (int statnum);
static bool bSerialOverride;
Expand Down
4 changes: 3 additions & 1 deletion wadsrc/static/zscript/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ class Thinker : Object native play
}

const TICRATE = 35;


static native int GetStatSize(int statnum);

virtual native void Tick();
virtual native void PostBeginPlay();
virtual native void ChangeStatNum(int stat);
Expand Down

0 comments on commit 3ba1146

Please sign in to comment.