isle/LEGO1/omni/src/video/mxloopingflcpresenter.cpp
Anonymous Maarten 9e686e2a87
cmake+ci: run clang-tidy (#512)
* cmake+ci: run clang-tidy

* Remove DESCRIPTION from LEGO1/LegoOmni.mingw.def

* Add initial .clang-tidy and fixes

* fix file perms

* Comment out DESCRIPTION

* Remove LegoEntity::~LegoEntity and MxPresenter::~MxPresenter from mingw's LEGO1.def

* Looks like clang is allergic to the libs in the directx5 SDK

* Update .clang-tidy

* Fix typo in .clang-tidy

* Attempt to generate an action error

* Revert "Attempt to generate an action error"

This reverts commit 96c4c65fed.

* cmake: test with -Wparentheses + optionally with -Werror

* ci: -k0 is a Ninja argument

* Use -Werror only for msys2 builds

* cmake: only emit warnings for specific warnings

* cmake: and don't do -Werror/-WX anymore

* Fix warnings

* Fix mingw warnings

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
2024-02-01 21:42:10 +01:00

134 lines
2.4 KiB
C++

#include "mxloopingflcpresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxLoopingFlcPresenter, 0x6c);
// FUNCTION: LEGO1 0x100b4310
MxLoopingFlcPresenter::MxLoopingFlcPresenter()
{
Init();
}
// FUNCTION: LEGO1 0x100b43b0
MxLoopingFlcPresenter::~MxLoopingFlcPresenter()
{
Destroy(TRUE);
}
// FUNCTION: LEGO1 0x100b4410
void MxLoopingFlcPresenter::Init()
{
this->m_elapsedDuration = 0;
SetBit1(FALSE);
SetBit2(FALSE);
}
// FUNCTION: LEGO1 0x100b4430
void MxLoopingFlcPresenter::Destroy(MxBool p_fromDestructor)
{
m_criticalSection.Enter();
Init();
m_criticalSection.Leave();
if (!p_fromDestructor) {
MxFlcPresenter::Destroy(FALSE);
}
}
// FUNCTION: LEGO1 0x100b4470
void MxLoopingFlcPresenter::NextFrame()
{
MxStreamChunk* chunk = NextChunk();
if (chunk->GetFlags() & MxDSChunk::c_end) {
ProgressTickleState(e_repeating);
}
else {
LoadFrame(chunk);
LoopChunk(chunk);
m_elapsedDuration += m_flcHeader->speed;
}
m_subscriber->DestroyChunk(chunk);
}
// FUNCTION: LEGO1 0x100b44c0
void MxLoopingFlcPresenter::VTable0x88()
{
if (m_action->GetDuration() < m_elapsedDuration) {
ProgressTickleState(e_unk5);
}
else {
MxStreamChunk* chunk;
m_loopingChunkCursor->Current(chunk);
LoadFrame(chunk);
m_elapsedDuration += m_flcHeader->speed;
}
}
// FUNCTION: LEGO1 0x100b4520
void MxLoopingFlcPresenter::RepeatingTickle()
{
for (MxS16 i = 0; i < m_unk0x5c; i++) {
if (!m_loopingChunkCursor->HasMatch()) {
MxStreamChunk* chunk;
MxStreamChunkListCursor cursor(m_loopingChunks);
cursor.Last(chunk);
MxLong time = chunk->GetTime();
cursor.First(chunk);
time -= chunk->GetTime();
time += m_flcHeader->speed;
cursor.Reset();
while (cursor.Next(chunk)) {
chunk->SetTime(chunk->GetTime() + time);
}
m_loopingChunkCursor->Next();
}
MxStreamChunk* chunk;
m_loopingChunkCursor->Current(chunk);
if (m_action->GetElapsedTime() < chunk->GetTime()) {
break;
}
VTable0x88();
m_loopingChunkCursor->Next(chunk);
if (m_currentTickleState != e_repeating) {
break;
}
}
}
// FUNCTION: LEGO1 0x100b4860
MxResult MxLoopingFlcPresenter::AddToManager()
{
MxResult result = FAILURE;
MxBool locked = FALSE;
if (MxFlcPresenter::AddToManager() == SUCCESS) {
m_criticalSection.Enter();
locked = TRUE;
result = SUCCESS;
}
if (locked) {
m_criticalSection.Leave();
}
return result;
}
// FUNCTION: LEGO1 0x100b48a0
void MxLoopingFlcPresenter::Destroy()
{
Destroy(FALSE);
}