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>
This commit is contained in:
Anonymous Maarten
2024-02-01 21:42:10 +01:00
committed by GitHub
parent 97d1ba7c71
commit 9e686e2a87
308 changed files with 2863 additions and 1995 deletions

View File

@@ -108,8 +108,9 @@ MxU32 MxDSAction::GetSizeOnDisk()
// FUNCTION: LEGO1 0x100adc10
MxDSAction& MxDSAction::operator=(MxDSAction& p_dsAction)
{
if (this == &p_dsAction)
if (this == &p_dsAction) {
return *this;
}
MxDSObject::operator=(p_dsAction);
this->CopyFrom(p_dsAction);
@@ -121,8 +122,9 @@ MxDSAction* MxDSAction::Clone()
{
MxDSAction* clone = new MxDSAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -136,35 +138,47 @@ MxLong MxDSAction::GetElapsedTime()
// FUNCTION: LEGO1 0x100add00
void MxDSAction::MergeFrom(MxDSAction& p_dsAction)
{
if (p_dsAction.m_startTime != INT_MIN)
if (p_dsAction.m_startTime != INT_MIN) {
this->m_startTime = p_dsAction.m_startTime;
}
if (p_dsAction.GetDuration() != INT_MIN)
if (p_dsAction.GetDuration() != INT_MIN) {
this->m_duration = p_dsAction.GetDuration();
}
if (p_dsAction.m_loopCount != -1)
if (p_dsAction.m_loopCount != -1) {
this->m_loopCount = p_dsAction.m_loopCount;
}
if (p_dsAction.m_location[0] != FLT_MAX)
if (p_dsAction.m_location[0] != FLT_MAX) {
this->m_location[0] = p_dsAction.m_location[0];
if (p_dsAction.m_location[1] != FLT_MAX)
}
if (p_dsAction.m_location[1] != FLT_MAX) {
this->m_location[1] = p_dsAction.m_location[1];
if (p_dsAction.m_location[2] != FLT_MAX)
}
if (p_dsAction.m_location[2] != FLT_MAX) {
this->m_location[2] = p_dsAction.m_location[2];
}
if (p_dsAction.m_direction[0] != FLT_MAX)
if (p_dsAction.m_direction[0] != FLT_MAX) {
this->m_direction[0] = p_dsAction.m_direction[0];
if (p_dsAction.m_direction[1] != FLT_MAX)
}
if (p_dsAction.m_direction[1] != FLT_MAX) {
this->m_direction[1] = p_dsAction.m_direction[1];
if (p_dsAction.m_direction[2] != FLT_MAX)
}
if (p_dsAction.m_direction[2] != FLT_MAX) {
this->m_direction[2] = p_dsAction.m_up[2]; // This is correct
}
if (p_dsAction.m_up[0] != FLT_MAX)
if (p_dsAction.m_up[0] != FLT_MAX) {
this->m_up[0] = p_dsAction.m_up[0];
if (p_dsAction.m_up[1] != FLT_MAX)
}
if (p_dsAction.m_up[1] != FLT_MAX) {
this->m_up[1] = p_dsAction.m_up[1];
if (p_dsAction.m_up[2] != FLT_MAX)
}
if (p_dsAction.m_up[2] != FLT_MAX) {
this->m_up[2] = p_dsAction.m_up[2];
}
MxU16 extraLength = p_dsAction.m_extraLength;
char* extraData = p_dsAction.m_extraData;
@@ -185,8 +199,9 @@ void MxDSAction::MergeFrom(MxDSAction& p_dsAction)
// FUNCTION: LEGO1 0x100ade60
void MxDSAction::AppendData(MxU16 p_extraLength, const char* p_extraData)
{
if (this->m_extraData == p_extraData || !p_extraData)
if (this->m_extraData == p_extraData || !p_extraData) {
return;
}
if (this->m_extraLength) {
char* concat = new char[p_extraLength + this->m_extraLength + sizeof(g_sep)];

View File

@@ -21,8 +21,9 @@ void MxDSAnim::CopyFrom(MxDSAnim& p_dsAnim)
// FUNCTION: LEGO1 0x100c9200
MxDSAnim& MxDSAnim::operator=(MxDSAnim& p_dsAnim)
{
if (this == &p_dsAnim)
if (this == &p_dsAnim) {
return *this;
}
MxDSMediaAction::operator=(p_dsAnim);
this->CopyFrom(p_dsAnim);
@@ -34,8 +35,9 @@ MxDSAction* MxDSAnim::Clone()
{
MxDSAnim* clone = new MxDSAnim();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -21,8 +21,9 @@ void MxDSEvent::CopyFrom(MxDSEvent& p_dsEvent)
// FUNCTION: LEGO1 0x100c9800
MxDSEvent& MxDSEvent::operator=(MxDSEvent& p_dsEvent)
{
if (this == &p_dsEvent)
if (this == &p_dsEvent) {
return *this;
}
MxDSMediaAction::operator=(p_dsEvent);
this->CopyFrom(p_dsEvent);
@@ -34,8 +35,9 @@ MxDSAction* MxDSEvent::Clone()
{
MxDSEvent* clone = new MxDSEvent();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -39,8 +39,9 @@ void MxDSMediaAction::CopyFrom(MxDSMediaAction& p_dsMediaAction)
// FUNCTION: LEGO1 0x100c8dc0
MxDSMediaAction& MxDSMediaAction::operator=(MxDSMediaAction& p_dsMediaAction)
{
if (this == &p_dsMediaAction)
if (this == &p_dsMediaAction) {
return *this;
}
MxDSAction::operator=(p_dsMediaAction);
this->CopyFrom(p_dsMediaAction);
@@ -52,8 +53,9 @@ MxDSAction* MxDSMediaAction::Clone()
{
MxDSMediaAction* clone = new MxDSMediaAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -61,18 +63,21 @@ MxDSAction* MxDSMediaAction::Clone()
// FUNCTION: LEGO1 0x100c8e80
void MxDSMediaAction::CopyMediaSrcPath(const char* p_mediaSrcPath)
{
if (this->m_mediaSrcPath == p_mediaSrcPath)
if (this->m_mediaSrcPath == p_mediaSrcPath) {
return;
}
delete[] this->m_mediaSrcPath;
if (p_mediaSrcPath) {
this->m_mediaSrcPath = new char[strlen(p_mediaSrcPath) + 1];
if (this->m_mediaSrcPath)
if (this->m_mediaSrcPath) {
strcpy(this->m_mediaSrcPath, p_mediaSrcPath);
}
}
else
else {
this->m_mediaSrcPath = NULL;
}
}
// FUNCTION: LEGO1 0x100c8f00
@@ -86,10 +91,12 @@ MxU32 MxDSMediaAction::GetSizeOnDisk()
{
MxU32 totalSizeOnDisk = MxDSAction::GetSizeOnDisk();
if (this->m_mediaSrcPath)
if (this->m_mediaSrcPath) {
totalSizeOnDisk += strlen(this->m_mediaSrcPath) + 1;
else
}
else {
totalSizeOnDisk++;
}
totalSizeOnDisk += 24;
this->m_sizeOnDisk = totalSizeOnDisk - MxDSAction::GetSizeOnDisk();

View File

@@ -15,8 +15,9 @@ MxDSMultiAction::MxDSMultiAction()
// FUNCTION: LEGO1 0x100ca060
MxDSMultiAction::~MxDSMultiAction()
{
if (this->m_actions)
if (this->m_actions) {
delete this->m_actions;
}
}
// FUNCTION: LEGO1 0x100ca0d0
@@ -26,15 +27,17 @@ void MxDSMultiAction::CopyFrom(MxDSMultiAction& p_dsMultiAction)
MxDSActionListCursor cursor(p_dsMultiAction.m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
this->m_actions->Append(action->Clone());
}
}
// FUNCTION: LEGO1 0x100ca260
MxDSMultiAction& MxDSMultiAction::operator=(MxDSMultiAction& p_dsMultiAction)
{
if (this == &p_dsMultiAction)
if (this == &p_dsMultiAction) {
return *this;
}
MxDSAction::operator=(p_dsMultiAction);
this->CopyFrom(p_dsMultiAction);
@@ -48,8 +51,9 @@ void MxDSMultiAction::SetUnknown90(MxLong p_unk0x90)
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
action->SetUnknown90(p_unk0x90);
}
}
// FUNCTION: LEGO1 0x100ca370
@@ -59,21 +63,24 @@ void MxDSMultiAction::MergeFrom(MxDSAction& p_dsMultiAction)
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
action->MergeFrom(p_dsMultiAction);
}
}
// FUNCTION: LEGO1 0x100ca450
MxBool MxDSMultiAction::HasId(MxU32 p_objectId)
{
if (this->GetObjectId() == p_objectId)
if (this->GetObjectId() == p_objectId) {
return TRUE;
}
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action)) {
if (action->HasId(p_objectId))
if (action->HasId(p_objectId)) {
return TRUE;
}
}
return FALSE;
@@ -84,8 +91,9 @@ MxDSAction* MxDSMultiAction::Clone()
{
MxDSMultiAction* clone = new MxDSMultiAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -97,8 +105,9 @@ undefined4 MxDSMultiAction::VTable0x14()
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
result += action->VTable0x14();
}
return result;
}
@@ -110,8 +119,9 @@ MxU32 MxDSMultiAction::GetSizeOnDisk()
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
totalSizeOnDisk += action->GetSizeOnDisk();
}
this->m_sizeOnDisk = totalSizeOnDisk - MxDSAction::GetSizeOnDisk();
@@ -151,6 +161,7 @@ void MxDSMultiAction::SetAtomId(MxAtomId p_atomId)
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
action->SetAtomId(p_atomId);
}
}

View File

@@ -52,8 +52,9 @@ void MxDSObject::CopyFrom(MxDSObject& p_dsObject)
// FUNCTION: LEGO1 0x100bf8c0
MxDSObject& MxDSObject::operator=(MxDSObject& p_dsObject)
{
if (this == &p_dsObject)
if (this == &p_dsObject) {
return *this;
}
this->CopyFrom(p_dsObject);
return *this;
@@ -108,17 +109,21 @@ MxU32 MxDSObject::GetSizeOnDisk()
{
MxU32 sizeOnDisk;
if (this->m_sourceName)
if (this->m_sourceName) {
sizeOnDisk = strlen(this->m_sourceName) + 3;
else
}
else {
sizeOnDisk = 3;
}
sizeOnDisk += 4;
if (this->m_objectName)
if (this->m_objectName) {
sizeOnDisk += strlen(this->m_objectName) + 1;
else
}
else {
sizeOnDisk++;
}
sizeOnDisk += 4;
this->m_sizeOnDisk = sizeOnDisk;

View File

@@ -21,8 +21,9 @@ void MxDSObjectAction::CopyFrom(MxDSObjectAction& p_dsObjectAction)
// FUNCTION: LEGO1 0x100c8a80
MxDSObjectAction& MxDSObjectAction::operator=(MxDSObjectAction& p_dsObjectAction)
{
if (this == &p_dsObjectAction)
if (this == &p_dsObjectAction) {
return *this;
}
MxDSMediaAction::operator=(p_dsObjectAction);
this->CopyFrom(p_dsObjectAction);
@@ -34,8 +35,9 @@ MxDSAction* MxDSObjectAction::Clone()
{
MxDSObjectAction* clone = new MxDSObjectAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -23,8 +23,9 @@ void MxDSParallelAction::CopyFrom(MxDSParallelAction& p_dsParallelAction)
// FUNCTION: LEGO1 0x100cb0a0
MxDSParallelAction& MxDSParallelAction::operator=(MxDSParallelAction& p_dsParallelAction)
{
if (this == &p_dsParallelAction)
if (this == &p_dsParallelAction) {
return *this;
}
MxDSMultiAction::operator=(p_dsParallelAction);
this->CopyFrom(p_dsParallelAction);
@@ -36,8 +37,9 @@ MxDSAction* MxDSParallelAction::Clone()
{
MxDSParallelAction* clone = new MxDSParallelAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -45,15 +47,17 @@ MxDSAction* MxDSParallelAction::Clone()
// FUNCTION: LEGO1 0x100cb160
MxLong MxDSParallelAction::GetDuration()
{
if (this->m_duration)
if (this->m_duration) {
return this->m_duration;
}
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action)) {
if (!action)
if (!action) {
continue;
}
MxLong duration = action->GetDuration();
if (duration == -1) {
@@ -65,10 +69,12 @@ MxLong MxDSParallelAction::GetDuration()
if (action->IsA("MxDSMediaAction")) {
MxLong sustainTime = ((MxDSMediaAction*) action)->GetSustainTime();
if (sustainTime == -1)
if (sustainTime == -1) {
duration = -1;
else if (sustainTime)
}
else if (sustainTime) {
duration += sustainTime;
}
}
if (duration == -1) {
@@ -76,12 +82,14 @@ MxLong MxDSParallelAction::GetDuration()
break;
}
if (this->m_duration < duration)
if (this->m_duration < duration) {
this->m_duration = duration;
}
}
if (this->IsBit3())
if (this->IsBit3()) {
this->m_duration *= this->m_loopCount;
}
return this->m_duration;
}

View File

@@ -19,8 +19,9 @@ MxDSSelectAction::MxDSSelectAction()
// FUNCTION: LEGO1 0x100cb8d0
MxDSSelectAction::~MxDSSelectAction()
{
if (this->m_unk0xac)
if (this->m_unk0xac) {
delete this->m_unk0xac;
}
}
// FUNCTION: LEGO1 0x100cb950
@@ -32,8 +33,9 @@ void MxDSSelectAction::CopyFrom(MxDSSelectAction& p_dsSelectAction)
MxStringListCursor cursor(p_dsSelectAction.m_unk0xac);
MxString string;
while (cursor.Next(string))
while (cursor.Next(string)) {
this->m_unk0xac->Append(string);
}
}
// FUNCTION: LEGO1 0x100cbd50
@@ -51,8 +53,9 @@ MxDSAction* MxDSSelectAction::Clone()
{
MxDSSelectAction* clone = new MxDSSelectAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -66,8 +69,9 @@ MxU32 MxDSSelectAction::GetSizeOnDisk()
MxStringListCursor cursor(this->m_unk0xac);
MxString string;
while (cursor.Next(string))
while (cursor.Next(string)) {
totalSizeOnDisk += strlen(string.GetData()) + 1;
}
// Note: unlike the other classes, MxDSSelectAction does not have its own
// sizeOnDisk member. Instead, it overrides the one from MxDSMultiAction.
@@ -95,8 +99,9 @@ void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
MxS32 random = rand() % value;
string = itoa((MxS16) random, buffer, 10);
}
else
else {
string = VariableTable()->GetVariable((char*) *p_source);
}
*p_source += strlen((char*) *p_source) + 1;
@@ -109,8 +114,9 @@ void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
MxU32 i;
for (i = 0; i < count; i++) {
if (!strcmp(string.GetData(), (char*) *p_source))
if (!strcmp(string.GetData(), (char*) *p_source)) {
index = i;
}
this->m_unk0xac->Append((char*) *p_source);
*p_source += strlen((char*) *p_source) + 1;
@@ -122,10 +128,12 @@ void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24);
if (index == i)
if (index == i) {
this->m_actions->Append(action);
else
}
else {
delete action;
}
*p_source += extraFlag;
}

View File

@@ -21,8 +21,9 @@ void MxDSSerialAction::SetDuration(MxLong p_duration)
// FUNCTION: LEGO1 0x100cac10
MxDSSerialAction::~MxDSSerialAction()
{
if (this->m_cursor)
if (this->m_cursor) {
delete this->m_cursor;
}
this->m_cursor = NULL;
}
@@ -35,8 +36,9 @@ void MxDSSerialAction::CopyFrom(MxDSSerialAction& p_dsSerialAction)
// FUNCTION: LEGO1 0x100caca0
MxDSSerialAction& MxDSSerialAction::operator=(MxDSSerialAction& p_dsSerialAction)
{
if (this == &p_dsSerialAction)
if (this == &p_dsSerialAction) {
return *this;
}
MxDSMultiAction::operator=(p_dsSerialAction);
this->CopyFrom(p_dsSerialAction);
@@ -48,8 +50,9 @@ MxDSAction* MxDSSerialAction::Clone()
{
MxDSSerialAction* clone = new MxDSSerialAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -57,23 +60,26 @@ MxDSAction* MxDSSerialAction::Clone()
// FUNCTION: LEGO1 0x100cad60
MxLong MxDSSerialAction::GetDuration()
{
if (this->m_duration)
if (this->m_duration) {
return this->m_duration;
}
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action)) {
if (!action)
if (!action) {
continue;
}
this->m_duration += action->GetDuration() + action->GetStartTime();
if (action->IsA("MxDSMediaAction")) {
MxLong sustainTime = ((MxDSMediaAction*) action)->GetSustainTime();
if (sustainTime && sustainTime != -1)
if (sustainTime && sustainTime != -1) {
this->m_duration += sustainTime;
}
}
}

View File

@@ -26,8 +26,9 @@ void MxDSSound::CopyFrom(MxDSSound& p_dsSound)
// FUNCTION: LEGO1 0x100c94e0
MxDSSound& MxDSSound::operator=(MxDSSound& p_dsSound)
{
if (this == &p_dsSound)
if (this == &p_dsSound) {
return *this;
}
MxDSMediaAction::operator=(p_dsSound);
this->CopyFrom(p_dsSound);
@@ -39,8 +40,9 @@ MxDSAction* MxDSSound::Clone()
{
MxDSSound* clone = new MxDSSound();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -21,8 +21,9 @@ void MxDSStill::CopyFrom(MxDSStill& p_dsStill)
// FUNCTION: LEGO1 0x100c9ad0
MxDSStill& MxDSStill::operator=(MxDSStill& p_dsStill)
{
if (this == &p_dsStill)
if (this == &p_dsStill) {
return *this;
}
MxDSMediaAction::operator=(p_dsStill);
this->CopyFrom(p_dsStill);
@@ -34,8 +35,9 @@ MxDSAction* MxDSStill::Clone()
{
MxDSStill* clone = new MxDSStill();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -17,8 +17,9 @@ MxDSStreamingAction::MxDSStreamingAction(MxDSAction& p_dsAction, MxU32 p_offset)
// FUNCTION: LEGO1 0x100cd090
MxBool MxDSStreamingAction::HasId(MxU32 p_objectId)
{
if (this->m_internalAction)
if (this->m_internalAction) {
return this->m_internalAction->HasId(p_objectId);
}
return FALSE;
}
@@ -32,12 +33,15 @@ MxDSStreamingAction::MxDSStreamingAction(MxDSStreamingAction& p_dsStreamingActio
// FUNCTION: LEGO1 0x100cd150
MxDSStreamingAction::~MxDSStreamingAction()
{
if (this->m_unk0xa0)
if (this->m_unk0xa0) {
delete this->m_unk0xa0;
if (this->m_unk0xa4)
}
if (this->m_unk0xa4) {
delete this->m_unk0xa4;
if (this->m_internalAction)
}
if (this->m_internalAction) {
delete this->m_internalAction;
}
}
// FUNCTION: LEGO1 0x100cd1e0
@@ -73,16 +77,18 @@ MxDSStreamingAction* MxDSStreamingAction::CopyFrom(MxDSStreamingAction& p_dsStre
// FUNCTION: LEGO1 0x100cd2a0
void MxDSStreamingAction::SetInternalAction(MxDSAction* p_dsAction)
{
if (this->m_internalAction)
if (this->m_internalAction) {
delete this->m_internalAction;
}
this->m_internalAction = p_dsAction;
}
// FUNCTION: LEGO1 0x100cd2d0
void MxDSStreamingAction::FUN_100cd2d0()
{
if (this->m_duration == -1)
if (this->m_duration == -1) {
return;
}
MxLong duration = this->m_duration / this->m_loopCount;
this->m_loopCount--;

View File

@@ -31,8 +31,9 @@ void MxAudioManager::Destroy(MxBool p_fromDestructor)
Init();
this->m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxMediaManager::Destroy();
}
}
// FUNCTION: LEGO1 0x100b8e40
@@ -48,11 +49,13 @@ MxResult MxAudioManager::InitPresenters()
g_count++;
}
if (result)
if (result) {
Destroy();
}
if (success)
if (success) {
this->m_criticalSection.Leave();
}
return result;
}

View File

@@ -20,17 +20,20 @@ void MxLoopingMIDIPresenter::StreamingTickle()
return;
}
if (m_chunk->GetTime() + m_action->GetDuration() <= m_action->GetElapsedTime())
if (m_chunk->GetTime() + m_action->GetDuration() <= m_action->GetElapsedTime()) {
ProgressTickleState(e_done);
}
}
// FUNCTION: LEGO1 0x100c2ae0
void MxLoopingMIDIPresenter::DoneTickle()
{
if (m_action->GetLoopCount())
if (m_action->GetLoopCount()) {
MxMIDIPresenter::DoneTickle();
else
}
else {
EndAction();
}
}
// FUNCTION: LEGO1 0x100c2b00

View File

@@ -34,14 +34,16 @@ void MxMIDIPresenter::Destroy(MxBool p_fromDestructor)
m_criticalSection.Enter();
if (m_subscriber && m_chunk)
if (m_subscriber && m_chunk) {
m_subscriber->DestroyChunk(m_chunk);
}
Init();
m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxMusicPresenter::Destroy();
}
}
// FUNCTION: LEGO1 0x100c2890
@@ -61,24 +63,28 @@ void MxMIDIPresenter::StartingTickle()
{
MxStreamChunk* chunk = CurrentChunk();
if (chunk && m_action->GetElapsedTime() >= chunk->GetTime())
if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) {
ProgressTickleState(e_streaming);
}
}
// FUNCTION: LEGO1 0x100c2910
void MxMIDIPresenter::StreamingTickle()
{
if (m_chunk)
if (m_chunk) {
ProgressTickleState(e_done);
else
}
else {
m_chunk = NextChunk();
}
}
// FUNCTION: LEGO1 0x100c2940
void MxMIDIPresenter::DoneTickle()
{
if (!MusicManager()->GetMIDIInitialized())
if (!MusicManager()->GetMIDIInitialized()) {
EndAction();
}
}
// FUNCTION: LEGO1 0x100c2960
@@ -95,8 +101,9 @@ MxResult MxMIDIPresenter::PutData()
if (m_currentTickleState == e_streaming && m_chunk && !MusicManager()->GetMIDIInitialized()) {
SetVolume(((MxDSSound*) m_action)->GetVolume());
if (MusicManager()->InitializeMIDI(m_chunk->GetData(), 1) != SUCCESS)
if (MusicManager()->InitializeMIDI(m_chunk->GetData(), 1) != SUCCESS) {
EndAction();
}
}
m_criticalSection.Leave();

View File

@@ -82,8 +82,9 @@ MxResult MxMusicManager::ResetStream()
}
if (m_midiHdrP->dwFlags & MHDR_DONE || m_midiHdrP->dwFlags & MHDR_PREPARED) {
if (midiOutUnprepareHeader((HMIDIOUT) m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR)) != MMSYSERR_NOERROR)
if (midiOutUnprepareHeader((HMIDIOUT) m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR)) != MMSYSERR_NOERROR) {
goto done;
}
memset(m_midiHdrP, 0, sizeof(MIDIHDR));
}
@@ -131,8 +132,9 @@ void MxMusicManager::SetMIDIVolume()
// FUNCTION: LEGO1 0x100c0820
void CALLBACK MxMusicManager::MidiCallbackProc(HDRVR p_hdrvr, UINT p_uMsg, DWORD p_dwUser, DWORD p_dw1, DWORD p_dw2)
{
if (p_uMsg == MOM_DONE)
if (p_uMsg == MOM_DONE) {
((MxMusicManager*) p_dwUser)->ResetStream();
}
}
// FUNCTION: LEGO1 0x100c0840
@@ -147,21 +149,25 @@ MxResult MxMusicManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
locked = TRUE;
m_thread = new MxTickleThread(this, p_frequencyMS);
if (!m_thread || m_thread->Start(0, 0) != SUCCESS)
if (!m_thread || m_thread->Start(0, 0) != SUCCESS) {
goto done;
}
}
else
else {
TickleManager()->RegisterClient(this, p_frequencyMS);
}
status = SUCCESS;
}
done:
if (status != SUCCESS)
if (status != SUCCESS) {
Destroy();
}
if (locked)
if (locked) {
m_criticalSection.Leave();
}
return status;
}
@@ -211,22 +217,26 @@ MxResult MxMusicManager::InitializeMIDI(MxU8* p_data, MxS32 p_loopCount)
for (; device < total; device++) {
MIDIOUTCAPSA caps;
midiOutGetDevCapsA(device, &caps, sizeof(MIDIOUTCAPSA));
if (caps.wTechnology == MOD_FMSYNTH)
if (caps.wTechnology == MOD_FMSYNTH) {
break;
}
}
if (device >= total)
if (device >= total) {
device = -1;
}
if (midiStreamOpen(&m_midiStreamH, &device, 1, (DWORD) MidiCallbackProc, (DWORD) this, CALLBACK_FUNCTION) !=
MMSYSERR_NOERROR)
MMSYSERR_NOERROR) {
goto done;
}
GetMIDIVolume(m_midiVolume);
m_midiHdrP = new MIDIHDR();
if (!m_midiHdrP)
if (!m_midiHdrP) {
goto done;
}
memset(m_midiHdrP, 0, sizeof(MIDIHDR));
@@ -236,8 +246,9 @@ MxResult MxMusicManager::InitializeMIDI(MxU8* p_data, MxS32 p_loopCount)
m_bufferOffset += 0x14;
timediv.dwTimeDiv = *((DWORD*) m_bufferOffset);
if (midiStreamProperty(m_midiStreamH, (LPBYTE) &timediv, MIDIPROP_SET | MIDIPROP_TIMEDIV) != MMSYSERR_NOERROR)
if (midiStreamProperty(m_midiStreamH, (LPBYTE) &timediv, MIDIPROP_SET | MIDIPROP_TIMEDIV) != MMSYSERR_NOERROR) {
goto done;
}
m_bufferOffset += 0x14;
m_bufferSize = *((MxU32*) m_bufferOffset);
@@ -246,12 +257,14 @@ MxResult MxMusicManager::InitializeMIDI(MxU8* p_data, MxS32 p_loopCount)
m_midiInitialized = TRUE;
ResetBuffer();
if (ResetStream() != SUCCESS)
if (ResetStream() != SUCCESS) {
goto done;
}
SetMIDIVolume();
if (midiStreamRestart(m_midiStreamH) != MMSYSERR_NOERROR)
if (midiStreamRestart(m_midiStreamH) != MMSYSERR_NOERROR) {
goto done;
}
result = SUCCESS;
}

View File

@@ -59,46 +59,55 @@ MxResult MxSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
MxResult status = FAILURE;
MxBool locked = FALSE;
if (MxAudioManager::InitPresenters() != SUCCESS)
if (MxAudioManager::InitPresenters() != SUCCESS) {
goto done;
}
m_criticalSection.Enter();
locked = TRUE;
if (DirectSoundCreate(NULL, &m_directSound, NULL) != DS_OK)
if (DirectSoundCreate(NULL, &m_directSound, NULL) != DS_OK) {
goto done;
}
if (m_directSound->SetCooperativeLevel(MxOmni::GetInstance()->GetWindowHandle(), DSSCL_PRIORITY) != DS_OK)
if (m_directSound->SetCooperativeLevel(MxOmni::GetInstance()->GetWindowHandle(), DSSCL_PRIORITY) != DS_OK) {
goto done;
}
DSBUFFERDESC desc;
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
if (MxOmni::IsSound3D())
if (MxOmni::IsSound3D()) {
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D;
else
}
else {
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME;
}
if (m_directSound->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK) {
if (!MxOmni::IsSound3D())
if (!MxOmni::IsSound3D()) {
goto done;
}
MxOmni::SetSound3D(FALSE);
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME;
if (m_directSound->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK)
if (m_directSound->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK) {
goto done;
}
}
WAVEFORMATEX format;
format.wFormatTag = WAVE_FORMAT_PCM;
if (MxOmni::IsSound3D())
if (MxOmni::IsSound3D()) {
format.nChannels = 2;
else
}
else {
format.nChannels = 1;
}
format.nSamplesPerSec = 11025; // KHz
format.wBitsPerSample = 16;
@@ -111,20 +120,24 @@ MxResult MxSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
if (p_createThread) {
m_thread = new MxTickleThread(this, p_frequencyMS);
if (!m_thread || m_thread->Start(0, 0) != SUCCESS)
if (!m_thread || m_thread->Start(0, 0) != SUCCESS) {
goto done;
}
}
else
else {
TickleManager()->RegisterClient(this, p_frequencyMS);
}
status = SUCCESS;
done:
if (status != SUCCESS)
if (status != SUCCESS) {
Destroy();
}
if (locked)
if (locked) {
m_criticalSection.Leave();
}
return status;
}
@@ -144,8 +157,9 @@ void MxSoundManager::SetVolume(MxS32 p_volume)
MxPresenter* presenter;
MxPresenterListCursor cursor(m_presenters);
while (cursor.Next(presenter))
while (cursor.Next(presenter)) {
((MxAudioPresenter*) presenter)->SetVolume(((MxAudioPresenter*) presenter)->GetVolume());
}
m_criticalSection.Leave();
}
@@ -160,8 +174,9 @@ MxPresenter* MxSoundManager::FUN_100aebd0(const MxAtomId& p_atomId, MxU32 p_obje
while (cursor.Next(presenter)) {
if (presenter->GetAction()->GetAtomId().GetInternal() == p_atomId.GetInternal() &&
presenter->GetAction()->GetObjectId() == p_objectId)
presenter->GetAction()->GetObjectId() == p_objectId) {
return presenter;
}
}
return NULL;
@@ -170,8 +185,9 @@ MxPresenter* MxSoundManager::FUN_100aebd0(const MxAtomId& p_atomId, MxU32 p_obje
// FUNCTION: LEGO1 0x100aecf0
MxS32 MxSoundManager::FUN_100aecf0(MxU32 p_undefined)
{
if (!p_undefined)
if (!p_undefined) {
return -10000;
}
return g_mxcoreCount[p_undefined];
}
@@ -183,9 +199,11 @@ void MxSoundManager::Pause()
MxPresenter* presenter;
MxPresenterListCursor cursor(m_presenters);
while (cursor.Next(presenter))
if (presenter->IsA("MxWavePresenter"))
while (cursor.Next(presenter)) {
if (presenter->IsA("MxWavePresenter")) {
((MxWavePresenter*) presenter)->Pause();
}
}
}
// FUNCTION: LEGO1 0x100aee10
@@ -196,7 +214,9 @@ void MxSoundManager::Resume()
MxPresenter* presenter;
MxPresenterListCursor cursor(m_presenters);
while (cursor.Next(presenter))
if (presenter->IsA("MxWavePresenter"))
while (cursor.Next(presenter)) {
if (presenter->IsA("MxWavePresenter")) {
((MxWavePresenter*) presenter)->Resume();
}
}
}

View File

@@ -8,15 +8,17 @@ DECOMP_SIZE_ASSERT(MxSoundPresenter, 0x54)
// FUNCTION: LEGO1 0x100b1a50
void MxSoundPresenter::Destroy(MxBool p_fromDestructor)
{
if (MSoundManager())
if (MSoundManager()) {
MSoundManager()->UnregisterPresenter(*this);
}
this->m_criticalSection.Enter();
MxMediaPresenter::Init();
this->m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxMediaPresenter::Destroy(FALSE);
}
}
// FUNCTION: LEGO1 0x100b1aa0

View File

@@ -40,13 +40,15 @@ void MxWavePresenter::Destroy(MxBool p_fromDestructor)
m_dsBuffer->Release();
}
if (m_waveFormat)
if (m_waveFormat) {
delete[] ((MxU8*) m_waveFormat);
}
Init();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxSoundPresenter::Destroy(FALSE);
}
}
// FUNCTION: LEGO1 0x100b1b60
@@ -55,8 +57,9 @@ MxS8 MxWavePresenter::GetPlayedChunks()
DWORD dwCurrentPlayCursor, dwCurrentWriteCursor;
MxS8 playedChunks = -1;
if (m_dsBuffer->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor) == DS_OK)
if (m_dsBuffer->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor) == DS_OK) {
playedChunks = dwCurrentPlayCursor / m_chunkLength;
}
return playedChunks;
}
@@ -141,26 +144,32 @@ void MxWavePresenter::StartingTickle()
waveFormatEx.nBlockAlign = m_waveFormat->m_pcmWaveFormat.wf.nBlockAlign;
waveFormatEx.wBitsPerSample = m_waveFormat->m_pcmWaveFormat.wBitsPerSample;
if (waveFormatEx.wBitsPerSample == 8)
if (waveFormatEx.wBitsPerSample == 8) {
m_silenceData = 0x7F;
}
if (waveFormatEx.wBitsPerSample == 16)
if (waveFormatEx.wBitsPerSample == 16) {
m_silenceData = 0;
}
DSBUFFERDESC desc;
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
if (m_unk0x66)
if (m_unk0x66) {
desc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME;
else
}
else {
desc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME;
}
if (m_action->GetFlags() & MxDSAction::c_looping)
if (m_action->GetFlags() & MxDSAction::c_looping) {
desc.dwBufferBytes = m_waveFormat->m_pcmWaveFormat.wf.nAvgBytesPerSec *
(m_action->GetDuration() / m_action->GetLoopCount()) / 1000;
else
}
else {
desc.dwBufferBytes = 2 * length;
}
desc.lpwfxFormat = &waveFormatEx;
@@ -209,19 +218,22 @@ void MxWavePresenter::DoneTickle()
MxS8 playedChunks = dwCurrentPlayCursor / m_chunkLength;
if (m_action->GetFlags() & MxDSAction::c_bit7 || m_action->GetFlags() & MxDSAction::c_looping ||
m_writtenChunks != playedChunks || m_lockSize + (m_chunkLength * playedChunks) <= dwCurrentPlayCursor)
m_writtenChunks != playedChunks || m_lockSize + (m_chunkLength * playedChunks) <= dwCurrentPlayCursor) {
MxMediaPresenter::DoneTickle();
}
}
else
else {
MxMediaPresenter::DoneTickle();
}
}
// FUNCTION: LEGO1 0x100b2130
void MxWavePresenter::LoopChunk(MxStreamChunk* p_chunk)
{
WriteToSoundBuffer(p_chunk->GetData(), p_chunk->GetLength());
if (IsEnabled())
if (IsEnabled()) {
m_subscriber->DestroyChunk(p_chunk);
}
}
// FUNCTION: LEGO1 0x100b2160
@@ -241,18 +253,21 @@ MxResult MxWavePresenter::PutData()
if (!m_started) {
m_dsBuffer->SetCurrentPosition(0);
if (m_dsBuffer->Play(0, 0, DSBPLAY_LOOPING) == DS_OK)
if (m_dsBuffer->Play(0, 0, DSBPLAY_LOOPING) == DS_OK) {
m_started = TRUE;
}
}
break;
case e_repeating:
if (m_started)
if (m_started) {
break;
}
m_dsBuffer->SetCurrentPosition(0);
if (m_dsBuffer->Play(0, 0, m_action->GetLoopCount() > 1) == DS_OK)
if (m_dsBuffer->Play(0, 0, m_action->GetLoopCount() > 1) == DS_OK) {
m_started = TRUE;
}
}
}
@@ -266,8 +281,9 @@ void MxWavePresenter::EndAction()
MxAutoLocker lock(&m_criticalSection);
MxMediaPresenter::EndAction();
if (m_dsBuffer)
if (m_dsBuffer) {
m_dsBuffer->Stop();
}
}
}
@@ -296,8 +312,9 @@ void MxWavePresenter::Enable(MxBool p_enable)
m_writtenChunks = 0;
m_started = FALSE;
}
else if (m_dsBuffer)
else if (m_dsBuffer) {
m_dsBuffer->Stop();
}
}
}
@@ -317,8 +334,9 @@ void MxWavePresenter::ParseExtra()
char soundValue[512];
if (KeyValueStringParse(soundValue, g_strSOUND, extraCopy)) {
if (!strcmpi(soundValue, "FALSE"))
if (!strcmpi(soundValue, "FALSE")) {
Enable(FALSE);
}
}
}
}
@@ -327,8 +345,9 @@ void MxWavePresenter::ParseExtra()
void MxWavePresenter::Pause()
{
if (!m_paused && m_started) {
if (m_dsBuffer)
if (m_dsBuffer) {
m_dsBuffer->Stop();
}
m_paused = TRUE;
}
}

View File

@@ -5,11 +5,13 @@
// FUNCTION: LEGO1 0x100acf90
MxAtomId::MxAtomId(const char* p_str, LookupMode p_mode)
{
if (!MxOmni::GetInstance())
if (!MxOmni::GetInstance()) {
return;
}
if (!AtomIdCounterSet())
if (!AtomIdCounterSet()) {
return;
}
MxAtomIdCounter* counter = GetCounter(p_str, p_mode);
m_internal = counter->GetKey()->GetData();
@@ -25,14 +27,17 @@ MxAtomId::~MxAtomId()
// FUNCTION: LEGO1 0x100acfe0
void MxAtomId::Destroy()
{
if (!m_internal)
if (!m_internal) {
return;
}
if (!MxOmni::GetInstance())
if (!MxOmni::GetInstance()) {
return;
}
if (!AtomIdCounterSet())
if (!AtomIdCounterSet()) {
return;
}
#ifdef COMPAT_MODE
MxAtomIdCounterSet::iterator it;
@@ -51,8 +56,9 @@ void MxAtomId::Destroy()
// FUNCTION: LEGO1 0x100ad1c0
MxAtomId& MxAtomId::operator=(const MxAtomId& p_atomId)
{
if (m_internal)
if (m_internal) {
Destroy();
}
if (p_atomId.m_internal && MxOmni::GetInstance() && AtomIdCounterSet()) {
MxAtomIdCounter* counter = GetCounter(p_atomId.m_internal, e_exact);

View File

@@ -14,6 +14,7 @@ void MxAtomIdCounter::Inc()
// FUNCTION: LEGO1 0x100ad800
void MxAtomIdCounter::Dec()
{
if (m_value)
if (m_value) {
m_value--;
}
}

View File

@@ -50,16 +50,18 @@ MxResult MxCompositePresenter::StartAction(MxStreamController* p_controller, MxD
if (presenter && presenter->AddToManager() == SUCCESS) {
presenter->SetCompositePresenter(this);
if (presenter->StartAction(p_controller, action) == SUCCESS)
if (presenter->StartAction(p_controller, action) == SUCCESS) {
success = TRUE;
}
}
if (success) {
action->SetOrigin(this);
m_list.push_back(presenter);
}
else if (presenter)
else if (presenter) {
delete presenter;
}
}
result = SUCCESS;
@@ -73,8 +75,9 @@ void MxCompositePresenter::EndAction()
{
MxAutoLocker lock(&m_criticalSection);
if (!m_action)
if (!m_action) {
return;
}
((MxDSMultiAction*) m_action)->GetActionList()->DeleteAll(FALSE);
@@ -139,15 +142,18 @@ void MxCompositePresenter::VTable0x58(MxEndActionNotificationParam& p_param)
MxDSActionList* actions = ((MxDSMultiAction*) m_action)->GetActionList();
MxDSActionListCursor cursor(actions);
if (cursor.Find(action))
if (cursor.Find(action)) {
cursor.Detach();
}
}
if (presenter)
if (presenter) {
delete presenter;
}
if (action)
if (action) {
delete action;
}
if (m_list.empty()) {
EndAction();
@@ -155,8 +161,9 @@ void MxCompositePresenter::VTable0x58(MxEndActionNotificationParam& p_param)
else {
if (m_action->IsA("MxDSSerialAction") && it != m_list.end()) {
MxPresenter* presenter = *it;
if (presenter->GetCurrentTickleState() == e_idle)
if (presenter->GetCurrentTickleState() == e_idle) {
presenter->SetTickleState(e_ready);
}
}
}
}
@@ -171,14 +178,16 @@ void MxCompositePresenter::VTable0x5c(MxNotificationParam& p_param)
if (*it == presenter) {
m_list.erase(it++);
if (presenter->GetCurrentTickleState() == e_idle)
if (presenter->GetCurrentTickleState() == e_idle) {
presenter->SetTickleState(e_ready);
}
MxDSActionList* actions = ((MxDSMultiAction*) m_action)->GetActionList();
MxDSActionListCursor cursor(actions);
if (cursor.Find(presenter->GetAction()))
if (cursor.Find(presenter->GetAction())) {
cursor.Detach();
}
if (m_list.empty()) {
EndAction();
@@ -186,8 +195,9 @@ void MxCompositePresenter::VTable0x5c(MxNotificationParam& p_param)
else {
if (m_action->IsA("MxDSSerialAction")) {
MxPresenter* presenter = *it;
if (presenter->GetCurrentTickleState() == e_idle)
if (presenter->GetCurrentTickleState() == e_idle) {
presenter->SetTickleState(e_ready);
}
}
}
@@ -205,13 +215,15 @@ void MxCompositePresenter::VTable0x60(MxPresenter* p_presenter)
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
if (*it == p_presenter) {
if (++it == m_list.end()) {
if (m_compositePresenter)
if (m_compositePresenter) {
m_compositePresenter->VTable0x60(this);
}
}
else if (m_action->IsA("MxDSSerialAction")) {
MxPresenter* presenter = *it;
if (presenter->GetCurrentTickleState() == e_idle)
if (presenter->GetCurrentTickleState() == e_idle) {
presenter->SetTickleState(e_ready);
}
}
return;
}
@@ -227,8 +239,9 @@ void MxCompositePresenter::SetTickleState(TickleState p_tickleState)
MxPresenter* presenter = *it;
presenter->SetTickleState(p_tickleState);
if (m_action->IsA("MxDSSerialAction") && p_tickleState == e_ready)
if (m_action->IsA("MxDSSerialAction") && p_tickleState == e_ready) {
return;
}
}
}
@@ -248,8 +261,9 @@ MxBool MxCompositePresenter::HasTickleStatePassed(TickleState p_tickleState)
{
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
MxPresenter* presenter = *it;
if (!presenter->HasTickleStatePassed(p_tickleState))
if (!presenter->HasTickleStatePassed(p_tickleState)) {
return FALSE;
}
}
return TRUE;

View File

@@ -50,8 +50,9 @@ void MxMediaManager::Destroy()
{
MxAutoLocker lock(&this->m_criticalSection);
if (this->m_presenters)
if (this->m_presenters) {
delete this->m_presenters;
}
Init();
}
@@ -63,13 +64,15 @@ MxResult MxMediaManager::Tickle()
MxPresenter* presenter;
MxPresenterListCursor cursor(this->m_presenters);
while (cursor.Next(presenter))
while (cursor.Next(presenter)) {
presenter->Tickle();
}
cursor.Reset();
while (cursor.Next(presenter))
while (cursor.Next(presenter)) {
presenter->PutData();
}
return SUCCESS;
}
@@ -88,8 +91,9 @@ void MxMediaManager::UnregisterPresenter(MxPresenter& p_presenter)
MxAutoLocker lock(&this->m_criticalSection);
MxPresenterListCursor cursor(this->m_presenters);
if (cursor.Find(&p_presenter))
if (cursor.Find(&p_presenter)) {
cursor.Detach();
}
}
// FUNCTION: LEGO1 0x100b8ac0
@@ -99,6 +103,7 @@ void MxMediaManager::StopPresenters()
MxPresenter* presenter;
MxPresenterListCursor cursor(this->m_presenters);
while (cursor.Next(presenter))
while (cursor.Next(presenter)) {
presenter->EndAction();
}
}

View File

@@ -26,21 +26,25 @@ void MxMediaPresenter::Destroy(MxBool p_fromDestructor)
{
MxAutoLocker lock(&m_criticalSection);
if (m_currentChunk && m_subscriber)
if (m_currentChunk && m_subscriber) {
m_subscriber->DestroyChunk(m_currentChunk);
}
if (m_subscriber)
if (m_subscriber) {
delete m_subscriber;
}
if (m_loopingChunkCursor)
if (m_loopingChunkCursor) {
delete m_loopingChunkCursor;
}
if (m_loopingChunks) {
MxStreamChunkListCursor cursor(m_loopingChunks);
MxStreamChunk* chunk;
while (cursor.Next(chunk))
while (cursor.Next(chunk)) {
chunk->Release();
}
delete m_loopingChunks;
}
@@ -48,8 +52,9 @@ void MxMediaPresenter::Destroy(MxBool p_fromDestructor)
Init();
}
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxPresenter::Destroy();
}
}
// FUNCTION: LEGO1 0x100b5650
@@ -102,16 +107,18 @@ MxResult MxMediaPresenter::StartAction(MxStreamController* p_controller, MxDSAct
m_loopingChunks = new MxStreamChunkList;
m_loopingChunkCursor = new MxStreamChunkListCursor(m_loopingChunks);
if (!m_loopingChunks && !m_loopingChunkCursor)
if (!m_loopingChunks && !m_loopingChunkCursor) {
goto done;
}
}
if (p_controller) {
m_subscriber = new MxDSSubscriber;
if (!m_subscriber ||
m_subscriber->Create(p_controller, p_action->GetObjectId(), p_action->GetUnknown24()) != SUCCESS)
m_subscriber->Create(p_controller, p_action->GetObjectId(), p_action->GetUnknown24()) != SUCCESS) {
goto done;
}
}
result = SUCCESS;
@@ -126,8 +133,9 @@ void MxMediaPresenter::EndAction()
{
MxAutoLocker lock(&m_criticalSection);
if (!m_action)
if (!m_action) {
return;
}
m_currentChunk = NULL;
@@ -198,18 +206,22 @@ void MxMediaPresenter::StreamingTickle()
void MxMediaPresenter::RepeatingTickle()
{
if (IsEnabled() && !m_currentChunk) {
if (m_loopingChunkCursor)
if (!m_loopingChunkCursor->Next(m_currentChunk))
if (m_loopingChunkCursor) {
if (!m_loopingChunkCursor->Next(m_currentChunk)) {
m_loopingChunkCursor->Next(m_currentChunk);
}
}
if (m_currentChunk) {
MxLong time = m_currentChunk->GetTime();
if (time <= m_action->GetElapsedTime() % m_action->GetLoopCount())
if (time <= m_action->GetElapsedTime() % m_action->GetLoopCount()) {
ProgressTickleState(e_unk5);
}
}
else {
if (m_action->GetElapsedTime() >= m_action->GetStartTime() + m_action->GetDuration())
if (m_action->GetElapsedTime() >= m_action->GetStartTime() + m_action->GetDuration()) {
ProgressTickleState(e_unk5);
}
}
}
}
@@ -248,8 +260,9 @@ void MxMediaPresenter::Enable(MxBool p_enable)
SetTickleState(e_repeating);
}
else {
if (m_loopingChunkCursor)
if (m_loopingChunkCursor) {
m_loopingChunkCursor->Reset();
}
m_currentChunk = NULL;
SetTickleState(e_done);
}

View File

@@ -49,8 +49,9 @@ MxResult MxPresenter::StartAction(MxStreamController*, MxDSAction* p_action)
// FUNCTION: LEGO1 0x100b4e40
void MxPresenter::EndAction()
{
if (this->m_action == NULL)
if (this->m_action == NULL) {
return;
}
MxAutoLocker lock(&this->m_criticalSection);
@@ -98,8 +99,9 @@ void MxPresenter::ParseExtra()
m_action->SetFlags(m_action->GetFlags() | MxDSAction::c_world);
if (result)
if (result) {
SendToCompositePresenter(MxOmni::GetInstance());
}
}
}
}
@@ -133,28 +135,33 @@ MxResult MxPresenter::Tickle()
case e_ready:
this->ReadyTickle();
if (m_currentTickleState != e_starting)
if (m_currentTickleState != e_starting) {
break;
}
case e_starting:
this->StartingTickle();
if (m_currentTickleState != e_streaming)
if (m_currentTickleState != e_streaming) {
break;
}
case e_streaming:
this->StreamingTickle();
if (m_currentTickleState != e_repeating)
if (m_currentTickleState != e_repeating) {
break;
}
case e_repeating:
this->RepeatingTickle();
if (m_currentTickleState != e_unk5)
if (m_currentTickleState != e_unk5) {
break;
}
case e_unk5:
this->Unk5Tickle();
if (m_currentTickleState != e_done)
if (m_currentTickleState != e_done) {
break;
}
case e_done:
this->DoneTickle();
default:
@@ -170,10 +177,12 @@ void MxPresenter::Enable(MxBool p_enable)
if (this->m_action && this->IsEnabled() != p_enable) {
MxU32 flags = this->m_action->GetFlags();
if (p_enable)
if (p_enable) {
this->m_action->SetFlags(flags | MxDSAction::c_enabled);
else
}
else {
this->m_action->SetFlags(flags & ~MxDSAction::c_enabled);
}
}
}

View File

@@ -45,8 +45,9 @@ MxResult MxTickleManager::Tickle()
else {
it++;
if (client->GetLastUpdateTime() > time)
if (client->GetLastUpdateTime() > time) {
client->SetLastUpdateTime(-client->GetTickleInterval());
}
if ((client->GetTickleInterval() + client->GetLastUpdateTime()) < time) {
client->GetClient()->Tickle();
@@ -64,8 +65,9 @@ void MxTickleManager::RegisterClient(MxCore* p_client, MxTime p_interval)
MxTime interval = GetClientTickleInterval(p_client);
if (interval == TICKLE_MANAGER_NOT_FOUND) {
MxTickleClient* client = new MxTickleClient(p_client, p_interval);
if (client != NULL)
if (client != NULL) {
m_clients.push_back(client);
}
}
}
@@ -102,8 +104,9 @@ MxTime MxTickleManager::GetClientTickleInterval(MxCore* p_client)
MxTickleClientPtrList::iterator it = m_clients.begin();
while (it != m_clients.end()) {
MxTickleClient* client = *it;
if ((client->GetClient() == p_client) && ((client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) == 0))
if ((client->GetClient() == p_client) && ((client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) == 0)) {
return client->GetTickleInterval();
}
it++;
}

View File

@@ -35,15 +35,17 @@ MxBool GetRectIntersection(
MxRect32 rect(0, 0, *p_width, *p_height);
rect.AddPoint(rect1Origin);
if (!rect.IntersectsWith(rect1))
if (!rect.IntersectsWith(rect1)) {
return FALSE;
}
rect.Intersect(rect1);
rect.SubtractPoint(rect1Origin);
rect.AddPoint(rect2Origin);
if (!rect.IntersectsWith(rect2))
if (!rect.IntersectsWith(rect2)) {
return FALSE;
}
rect.Intersect(rect2);
rect.SubtractPoint(rect2Origin);
@@ -93,8 +95,9 @@ MxBool KeyValueStringParse(char* p_outputValue, const char* p_key, const char* p
char* cur = &token[strlen(p_key)];
cur++;
while (*cur != ',') {
if (*cur == ' ' || *cur == '\0' || *cur == '\t' || *cur == '\n' || *cur == '\r')
if (*cur == ' ' || *cur == '\0' || *cur == '\t' || *cur == '\n' || *cur == '\r') {
break;
}
*p_outputValue++ = *cur++;
}
*p_outputValue = '\0';
@@ -115,8 +118,8 @@ MxBool KeyValueStringParse(char* p_outputValue, const char* p_key, const char* p
MxBool ContainsPresenter(MxCompositePresenterList& p_presenterList, MxPresenter* p_presenter)
{
for (MxCompositePresenterList::iterator it = p_presenterList.begin(); it != p_presenterList.end(); it++) {
if (p_presenter == *it || (*it)->IsA("MxCompositePresenter") &&
ContainsPresenter(((MxCompositePresenter*) *it)->GetList(), p_presenter)) {
if (p_presenter == *it || ((*it)->IsA("MxCompositePresenter") &&
ContainsPresenter(((MxCompositePresenter*) *it)->GetList(), p_presenter))) {
return TRUE;
}
}

View File

@@ -41,8 +41,9 @@ void MxVariableTable::SetVariable(MxVariable* p_var)
MxHashTableCursor<MxVariable*> cursor(this);
MxBool found = cursor.Find(p_var);
if (found)
if (found) {
cursor.DeleteMatch();
}
MxHashTable<MxVariable*>::Add(p_var);
}

View File

@@ -30,11 +30,13 @@ void MxEventManager::Destroy(MxBool p_fromDestructor)
m_thread->Terminate();
delete m_thread;
}
else
else {
TickleManager()->UnregisterClient(this);
}
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxMediaManager::Destroy();
}
}
// FUNCTION: LEGO1 0x100c04a0
@@ -50,21 +52,25 @@ MxResult MxEventManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
locked = TRUE;
this->m_thread = new MxTickleThread(this, p_frequencyMS);
if (!this->m_thread || this->m_thread->Start(0, 0) != SUCCESS)
if (!this->m_thread || this->m_thread->Start(0, 0) != SUCCESS) {
goto done;
}
}
else
else {
TickleManager()->RegisterClient(this, p_frequencyMS);
}
status = SUCCESS;
}
done:
if (status != SUCCESS)
if (status != SUCCESS) {
Destroy();
}
if (locked)
if (locked) {
this->m_criticalSection.Leave();
}
return status;
}

View File

@@ -42,13 +42,15 @@ MxResult MxEventPresenter::AddToManager()
// FUNCTION: LEGO1 0x100c2de0
void MxEventPresenter::Destroy()
{
if (EventManager())
if (EventManager()) {
EventManager()->UnregisterPresenter(*this);
}
m_criticalSection.Enter();
if (m_data)
if (m_data) {
delete[] m_data;
}
Init();
@@ -80,8 +82,9 @@ void MxEventPresenter::StartingTickle()
{
MxStreamChunk* chunk = CurrentChunk();
if (chunk && m_action->GetElapsedTime() >= chunk->GetTime())
if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) {
ProgressTickleState(e_streaming);
}
}
// FUNCTION: LEGO1 0x100c2ef0
@@ -103,8 +106,9 @@ MxResult MxEventPresenter::PutData()
variableTable->SetVariable(key, value);
}
if (m_currentTickleState == e_streaming)
if (m_currentTickleState == e_streaming) {
m_subscriber->DestroyChunk(m_currentChunk);
}
m_currentChunk = NULL;
}
}

View File

@@ -158,48 +158,56 @@ MxResult MxOmni::Create(MxOmniCreateParam& p_param)
{
MxResult result = FAILURE;
if (!(m_atomIdCounterSet = new MxAtomIdCounterSet()))
if (!(m_atomIdCounterSet = new MxAtomIdCounterSet())) {
goto done;
}
m_mediaPath = p_param.GetMediaPath();
m_windowHandle = p_param.GetWindowHandle();
if (p_param.CreateFlags().CreateObjectFactory()) {
if (!(m_objectFactory = new MxObjectFactory()))
if (!(m_objectFactory = new MxObjectFactory())) {
goto done;
}
}
if (p_param.CreateFlags().CreateVariableTable()) {
if (!(m_variableTable = new MxVariableTable()))
if (!(m_variableTable = new MxVariableTable())) {
goto done;
}
}
if (p_param.CreateFlags().CreateTimer()) {
if (!(m_timer = new MxTimer()))
if (!(m_timer = new MxTimer())) {
goto done;
}
}
if (p_param.CreateFlags().CreateTickleManager()) {
if (!(m_tickleManager = new MxTickleManager()))
if (!(m_tickleManager = new MxTickleManager())) {
goto done;
}
}
if (p_param.CreateFlags().CreateNotificationManager()) {
if (m_notificationManager = new MxNotificationManager()) {
if (m_notificationManager->Create(100, 0) != SUCCESS)
if ((m_notificationManager = new MxNotificationManager())) {
if (m_notificationManager->Create(100, 0) != SUCCESS) {
goto done;
}
}
else
else {
goto done;
}
}
if (p_param.CreateFlags().CreateStreamer()) {
if (!(m_streamer = new MxStreamer()) || m_streamer->Create() != SUCCESS)
if (!(m_streamer = new MxStreamer()) || m_streamer->Create() != SUCCESS) {
goto done;
}
}
if (p_param.CreateFlags().CreateVideoManager()) {
if (m_videoManager = new MxVideoManager()) {
if ((m_videoManager = new MxVideoManager())) {
if (m_videoManager->Create(p_param.GetVideoParam(), 100, 0) != SUCCESS) {
delete m_videoManager;
m_videoManager = NULL;
@@ -208,7 +216,7 @@ MxResult MxOmni::Create(MxOmniCreateParam& p_param)
}
if (p_param.CreateFlags().CreateSoundManager()) {
if (m_soundManager = new MxSoundManager()) {
if ((m_soundManager = new MxSoundManager())) {
if (m_soundManager->Create(10, 0) != SUCCESS) {
delete m_soundManager;
m_soundManager = NULL;
@@ -217,7 +225,7 @@ MxResult MxOmni::Create(MxOmniCreateParam& p_param)
}
if (p_param.CreateFlags().CreateMusicManager()) {
if (m_musicManager = new MxMusicManager()) {
if ((m_musicManager = new MxMusicManager())) {
if (m_musicManager->Create(50, 0) != SUCCESS) {
delete m_musicManager;
m_musicManager = NULL;
@@ -226,7 +234,7 @@ MxResult MxOmni::Create(MxOmniCreateParam& p_param)
}
if (p_param.CreateFlags().CreateEventManager()) {
if (m_eventManager = new MxEventManager()) {
if ((m_eventManager = new MxEventManager())) {
if (m_eventManager->Create(50, 0) != SUCCESS) {
delete m_eventManager;
m_eventManager = NULL;
@@ -235,9 +243,11 @@ MxResult MxOmni::Create(MxOmniCreateParam& p_param)
}
result = SUCCESS;
done:
if (result != SUCCESS)
if (result != SUCCESS) {
Destroy();
}
return result;
}
@@ -255,8 +265,9 @@ void MxOmni::Destroy()
// TODO: private members
if (m_notificationManager) {
while (m_notificationManager->GetQueue()) {
if (m_notificationManager->GetQueue()->size() == 0)
if (m_notificationManager->GetQueue()->size() == 0) {
break;
}
m_notificationManager->Tickle();
}
@@ -317,16 +328,18 @@ MxResult MxOmni::CreatePresenter(MxStreamController* p_controller, MxDSAction& p
if (object) {
if (object->AddToManager() == SUCCESS) {
MxPresenter* sender = p_action.GetUnknown28();
if (!sender)
if (!sender) {
sender = p_controller->FUN_100c1e70(p_action);
}
if (sender) {
p_action.SetOrigin(sender);
object->SetCompositePresenter((MxCompositePresenter*) sender);
}
else {
if (!p_action.GetOrigin())
if (!p_action.GetOrigin()) {
p_action.SetOrigin(this);
}
object->SetCompositePresenter(NULL);
}
@@ -381,16 +394,18 @@ void MxOmni::DestroyInstance()
// FUNCTION: LEGO1 0x100b06b0
MxBool MxOmni::ActionSourceEquals(MxDSAction* p_action, const char* p_name)
{
if (!strcmp(p_action->GetSourceName(), p_name))
if (!strcmp(p_action->GetSourceName(), p_name)) {
return TRUE;
}
if (p_action->IsA("MxDSMultiAction")) {
MxDSActionListCursor cursor(((MxDSMultiAction*) p_action)->GetActionList());
MxDSAction* action;
while (cursor.Next(action)) {
if (ActionSourceEquals(action, p_name))
if (ActionSourceEquals(action, p_name)) {
return TRUE;
}
}
}
@@ -402,8 +417,9 @@ MxLong MxOmni::Notify(MxParam& p_param)
{
MxAutoLocker lock(&this->m_criticalsection);
if (((MxNotificationParam&) p_param).GetNotification() != c_notificationEndAction)
if (((MxNotificationParam&) p_param).GetNotification() != c_notificationEndAction) {
return 0;
}
return HandleActionEnd(p_param);
}
@@ -476,8 +492,9 @@ MxBool MxOmni::DoesEntityExist(MxDSAction& p_dsAction)
if (m_streamer->FUN_100b9b30(p_dsAction)) {
MxNotificationPtrList* queue = m_notificationManager->GetQueue();
if (!queue || queue->size() == 0)
if (!queue || queue->size() == 0) {
return TRUE;
}
}
return FALSE;
}

View File

@@ -128,9 +128,9 @@ void MxNotificationManager::FlushPending(MxCore* p_listener)
MxNotificationPtrList::iterator it = m_sendList->begin();
while (it != m_sendList->end()) {
notif = *it;
if ((notif->GetTarget()->GetId() == p_listener->GetId()) ||
(notif->GetParam()->GetSender()) &&
(notif->GetParam()->GetSender()->GetId() == p_listener->GetId())) {
if (notif->GetTarget()->GetId() == p_listener->GetId() ||
(notif->GetParam()->GetSender() && notif->GetParam()->GetSender()->GetId() == p_listener->GetId()
)) {
m_sendList->erase(it++);
pending.push_back(notif);
}
@@ -143,8 +143,8 @@ void MxNotificationManager::FlushPending(MxCore* p_listener)
MxNotificationPtrList::iterator it = m_queue->begin();
while (it != m_queue->end()) {
notif = *it;
if ((notif->GetTarget()->GetId() == p_listener->GetId()) ||
(notif->GetParam()->GetSender()) && (notif->GetParam()->GetSender()->GetId() == p_listener->GetId())) {
if (notif->GetTarget()->GetId() == p_listener->GetId() ||
(notif->GetParam()->GetSender() && notif->GetParam()->GetSender()->GetId() == p_listener->GetId())) {
m_queue->erase(it++);
pending.push_back(notif);
}
@@ -169,8 +169,9 @@ void MxNotificationManager::Register(MxCore* p_listener)
MxAutoLocker lock(&m_lock);
MxIdList::iterator it = find(m_listenerIds.begin(), m_listenerIds.end(), p_listener->GetId());
if (it != m_listenerIds.end())
if (it != m_listenerIds.end()) {
return;
}
m_listenerIds.push_back(p_listener->GetId());
}

View File

@@ -35,8 +35,9 @@ MxDiskStreamController::~MxDiskStreamController()
}
MxDSAction* action;
while (m_unk0x3c.PopFront(action))
while (m_unk0x3c.PopFront(action)) {
delete action;
}
if (m_provider) {
delete m_provider;
@@ -45,11 +46,13 @@ MxDiskStreamController::~MxDiskStreamController()
FUN_100c8720();
while (m_list0x80.PopFront(action))
while (m_list0x80.PopFront(action)) {
FUN_100c7cb0((MxDSStreamingAction*) action);
}
while (m_list0x64.PopFront(action))
while (m_list0x64.PopFront(action)) {
FUN_100c7cb0((MxDSStreamingAction*) action);
}
while (!m_list0x74.empty()) {
MxDSBuffer* buffer = m_list0x74.front();
@@ -130,15 +133,17 @@ void MxDiskStreamController::FUN_100c7980()
buffer = new MxDSBuffer();
if (buffer->AllocateBuffer(m_provider->GetFileSize(), MxDSBuffer::e_chunk) != SUCCESS) {
if (buffer)
if (buffer) {
delete buffer;
}
return;
}
action = VTable0x28();
if (!action) {
if (buffer)
if (buffer) {
delete buffer;
}
return;
}
@@ -228,8 +233,9 @@ MxResult MxDiskStreamController::FUN_100c7d10()
MxAutoLocker lock(&this->m_criticalSection);
MxDSStreamingAction* action = FUN_100c7db0();
if (!action)
if (!action) {
return FAILURE;
}
if (FUN_100c8360(action) != SUCCESS) {
VTable0x24(action);
@@ -290,11 +296,13 @@ MxResult MxDiskStreamController::VTable0x20(MxDSAction* p_action)
FUN_100c7f40(action);
if (VTable0x2c(p_action, entry->GetUnknown94()) != SUCCESS)
if (VTable0x2c(p_action, entry->GetUnknown94()) != SUCCESS) {
return FAILURE;
}
}
else if (MxStreamController::VTable0x20(p_action) != SUCCESS)
else if (MxStreamController::VTable0x20(p_action) != SUCCESS) {
return FAILURE;
}
m_unk0x70 = TRUE;
m_unk0xc4 = TRUE;
@@ -312,8 +320,9 @@ void MxDiskStreamController::FUN_100c8120(MxDSAction* p_action)
while (TRUE) {
MxDSAction* found = m_unk0x54.Find(p_action, TRUE);
if (!found)
if (!found) {
break;
}
delete found;
}
}
@@ -408,8 +417,9 @@ void MxDiskStreamController::FUN_100c8540()
m_list0x74.erase(it++);
FUN_100c7ce0(buf);
}
else
else {
it++;
}
}
if (m_nextActionList.empty()) {

View File

@@ -19,8 +19,9 @@ MxU32 g_unk0x10102878 = 0;
// FUNCTION: LEGO1 0x100d0f30
MxResult MxDiskStreamProviderThread::Run()
{
if (m_target)
if (m_target) {
((MxDiskStreamProvider*) m_target)->WaitForWorkToComplete();
}
MxThread::Run();
// They should probably have writen "return MxThread::Run()" but they didn't.
return SUCCESS;
@@ -55,11 +56,13 @@ MxDiskStreamProvider::~MxDiskStreamProvider()
m_list.PopFrontStreamingAction(action);
}
if (!action)
if (!action) {
break;
}
if (action->GetUnknowna0()->GetWriteOffset() < 0x20000)
if (action->GetUnknowna0()->GetWriteOffset() < 0x20000) {
g_unk0x10102878--;
}
((MxDiskStreamController*) m_pLookup)->FUN_100c8670(action);
} while (action);
@@ -70,8 +73,9 @@ MxDiskStreamProvider::~MxDiskStreamProvider()
m_thread.Terminate();
}
if (m_pFile)
if (m_pFile) {
delete m_pFile;
}
m_pFile = NULL;
}
@@ -91,8 +95,9 @@ MxResult MxDiskStreamProvider::SetResourceToGet(MxStreamController* p_resource)
path = MxString(MxOmni::GetCD()) + p_resource->GetAtom().GetInternal() + ".si";
m_pFile->SetFileName(path.GetData());
if (m_pFile->Open(0) != 0)
if (m_pFile->Open(0) != 0) {
goto done;
}
}
m_remainingWork = TRUE;
@@ -123,11 +128,13 @@ void MxDiskStreamProvider::VTable0x20(MxDSAction* p_action)
m_list.PopFrontStreamingAction(action);
}
if (!action)
if (!action) {
return;
}
if (action->GetUnknowna0()->GetWriteOffset() < 0x20000)
if (action->GetUnknowna0()->GetWriteOffset() < 0x20000) {
g_unk0x10102878--;
}
((MxDiskStreamController*) m_pLookup)->FUN_100c8670(action);
} while (action);
@@ -139,11 +146,13 @@ void MxDiskStreamProvider::VTable0x20(MxDSAction* p_action)
action = (MxDSStreamingAction*) m_list.Find(p_action, TRUE);
}
if (!action)
if (!action) {
return;
}
if (action->GetUnknowna0()->GetWriteOffset() < 0x20000)
if (action->GetUnknowna0()->GetWriteOffset() < 0x20000) {
g_unk0x10102878--;
}
((MxDiskStreamController*) m_pLookup)->FUN_100c8670(action);
} while (action);
@@ -155,8 +164,9 @@ MxResult MxDiskStreamProvider::WaitForWorkToComplete()
{
while (m_remainingWork) {
m_busySemaphore.Wait(INFINITE);
if (m_unk0x35)
if (m_unk0x35) {
PerformWork();
}
}
return SUCCESS;
@@ -165,14 +175,16 @@ MxResult MxDiskStreamProvider::WaitForWorkToComplete()
// FUNCTION: LEGO1 0x100d1780
MxResult MxDiskStreamProvider::FUN_100d1780(MxDSStreamingAction* p_action)
{
if (!m_remainingWork)
if (!m_remainingWork) {
return FAILURE;
}
if (p_action->GetUnknown9c() > 0 && !p_action->GetUnknowna0()) {
MxDSBuffer* buffer = new MxDSBuffer();
if (!buffer)
if (!buffer) {
return FAILURE;
}
if (buffer->AllocateBuffer(GetFileSize(), MxDSBuffer::e_allocate) != SUCCESS) {
delete buffer;
@@ -220,8 +232,9 @@ void MxDiskStreamProvider::PerformWork()
{
MxAutoLocker lock(&m_criticalSection);
if (!m_list.PopFrontStreamingAction(streamingAction))
if (!m_list.PopFrontStreamingAction(streamingAction)) {
goto done;
}
}
if (streamingAction->GetUnknowna0()->GetWriteOffset() < 0x20000) {
@@ -276,15 +289,17 @@ MxResult MxDiskStreamProvider::FUN_100d1b20(MxDSStreamingAction* p_action)
{
MxDSBuffer* buffer = new MxDSBuffer();
if (!buffer)
if (!buffer) {
return FAILURE;
}
MxU32 size = p_action->GetUnknowna0()->GetWriteOffset() - p_action->GetUnknown94() + p_action->GetBufferOffset() +
(p_action->GetUnknowna4() ? p_action->GetUnknowna4()->GetWriteOffset() : 0);
if (buffer->AllocateBuffer(size, MxDSBuffer::e_allocate) != SUCCESS) {
if (!buffer)
if (!buffer) {
return FAILURE;
}
delete buffer;
return FAILURE;
@@ -327,8 +342,9 @@ MxResult MxDiskStreamProvider::FUN_100d1b20(MxDSStreamingAction* p_action)
size = ReadData(*pdata, buffer->GetWriteOffset());
MxDSBuffer* buffer3 = new MxDSBuffer();
if (!buffer3)
if (!buffer3) {
return FAILURE;
}
if (buffer3->AllocateBuffer(size, MxDSBuffer::e_allocate) == SUCCESS) {
memcpy(buffer3->GetBuffer(), p_action->GetUnknowna4()->GetBuffer(), size);
@@ -342,8 +358,9 @@ MxResult MxDiskStreamProvider::FUN_100d1b20(MxDSStreamingAction* p_action)
MxU8* data2 = buffer4->GetBuffer();
while (TRUE) {
if (*MxStreamChunk::IntoTime(data2) > p_action->GetUnknown9c())
if (*MxStreamChunk::IntoTime(data2) > p_action->GetUnknown9c()) {
break;
}
data += MxDSChunk::Size(*MxDSChunk::IntoLength(data));
unk0x14 += MxDSChunk::Size(*MxDSChunk::IntoLength(data));

View File

@@ -164,19 +164,22 @@ MxResult MxDSBuffer::FUN_100c67b0(
MxResult result = FAILURE;
m_unk0x30 = (MxDSStreamingAction*) p_controller->GetUnk0x3c().Find(p_action, FALSE);
if (m_unk0x30 == NULL)
if (m_unk0x30 == NULL) {
return FAILURE;
}
MxU8* data;
while (data = (MxU8*) SkipToData()) {
while ((data = (MxU8*) SkipToData())) {
if (*p_streamingAction == NULL) {
result = CreateObject(p_controller, (MxU32*) data, p_action, p_streamingAction);
if (result == FAILURE)
if (result == FAILURE) {
return result;
}
// TODO: Not a MxResult value?
if (result == 1)
if (result == 1) {
break;
}
}
else {
MxDSBuffer* buffer = (*p_streamingAction)->GetUnknowna0();
@@ -226,8 +229,9 @@ MxResult MxDSBuffer::CreateObject(
return FAILURE;
}
if (*p_data == FOURCC('M', 'x', 'O', 'b'))
if (*p_data == FOURCC('M', 'x', 'O', 'b')) {
return StartPresenterFromAction(p_controller, p_action, (MxDSAction*) header);
}
else if (*p_data == FOURCC('M', 'x', 'C', 'h')) {
MxStreamChunk* chunk = (MxStreamChunk*) header;
if (!m_unk0x30->HasId((chunk)->GetObjectId())) {
@@ -316,8 +320,9 @@ MxResult MxDSBuffer::ParseChunk(
}
}
if (buffer)
if (buffer) {
delete buffer;
}
delete p_header;
return FAILURE;
@@ -337,8 +342,9 @@ MxResult MxDSBuffer::ParseChunk(
MxNextActionDataStart* data =
p_controller->FindNextActionDataStartFromStreamingAction(m_unk0x30);
if (data)
if (data) {
data->SetData(m_unk0x30->GetBufferOffset());
}
m_unk0x30->FUN_100cd2d0();
}
@@ -472,8 +478,9 @@ MxResult MxDSBuffer::CalcBytesRemaining(MxU8* p_data)
if (bytesRead <= m_bytesRemaining) {
memcpy(m_pBuffer + m_writeOffset - m_bytesRemaining, ptr, bytesRead);
if (m_writeOffset == m_bytesRemaining)
if (m_writeOffset == m_bytesRemaining) {
*(MxU32*) (m_pBuffer + 4) = *MxStreamChunk::IntoLength(m_pBuffer) + MxStreamChunk::GetHeaderSize();
}
m_bytesRemaining -= bytesRead;
result = SUCCESS;
@@ -510,8 +517,9 @@ MxU8* MxDSBuffer::FUN_100c6fa0(MxU8* p_data)
break;
case FOURCC('M', 'x', 'O', 'b'):
case FOURCC('M', 'x', 'C', 'h'):
if (current != p_data)
if (current != p_data) {
return current;
}
current = ((MxU32) current & 1) + current;
current += 8;
break;

View File

@@ -15,8 +15,9 @@ MxDSChunk::MxDSChunk()
// FUNCTION: LEGO1 0x100be170
MxDSChunk::~MxDSChunk()
{
if (m_flags & c_bit1)
if (m_flags & c_bit1) {
delete[] m_data;
}
}
// FUNCTION: LEGO1 0x100be1e0

View File

@@ -98,8 +98,9 @@ MxLong MxDSFile::Close()
// FUNCTION: LEGO1 0x100cc780
MxResult MxDSFile::Read(unsigned char* p_buf, MxULong p_nbytes)
{
if (m_io.Read(p_buf, p_nbytes) != p_nbytes)
if (m_io.Read(p_buf, p_nbytes) != p_nbytes) {
return FAILURE;
}
m_position += p_nbytes;
return SUCCESS;

View File

@@ -16,17 +16,20 @@ MxDSSubscriber::MxDSSubscriber()
// FUNCTION: LEGO1 0x100b7e00
MxDSSubscriber::~MxDSSubscriber()
{
if (m_controller)
if (m_controller) {
m_controller->RemoveSubscriber(this);
}
DeleteChunks();
if (m_pendingChunkCursor)
if (m_pendingChunkCursor) {
delete m_pendingChunkCursor;
}
m_pendingChunkCursor = NULL;
if (m_consumedChunkCursor)
if (m_consumedChunkCursor) {
delete m_consumedChunkCursor;
}
m_consumedChunkCursor = NULL;
}
@@ -36,17 +39,20 @@ MxResult MxDSSubscriber::Create(MxStreamController* p_controller, MxU32 p_object
m_objectId = p_objectId;
m_unk0x48 = p_unk0x48;
if (!p_controller)
if (!p_controller) {
return FAILURE;
}
m_controller = p_controller;
m_pendingChunkCursor = new MxStreamChunkListCursor(&m_pendingChunks);
if (!m_pendingChunkCursor)
if (!m_pendingChunkCursor) {
return FAILURE;
}
m_consumedChunkCursor = new MxStreamChunkListCursor(&m_consumedChunks);
if (!m_consumedChunkCursor)
if (!m_consumedChunkCursor) {
return FAILURE;
}
m_controller->AddSubscriber(this);
return SUCCESS;
@@ -74,10 +80,12 @@ void MxDSSubscriber::DeleteChunks()
MxResult MxDSSubscriber::AddChunk(MxStreamChunk* p_chunk, MxBool p_append)
{
if (m_pendingChunkCursor) {
if (p_append)
if (p_append) {
m_pendingChunks.Append(p_chunk);
else
}
else {
m_pendingChunks.Prepend(p_chunk);
}
}
return SUCCESS;
@@ -88,8 +96,9 @@ MxStreamChunk* MxDSSubscriber::NextChunk()
{
MxStreamChunk* chunk = NULL;
if (m_pendingChunkCursor)
if (m_pendingChunkCursor) {
m_pendingChunkCursor->First(chunk);
}
if (chunk) {
m_pendingChunkCursor->Detach();
@@ -104,8 +113,9 @@ MxStreamChunk* MxDSSubscriber::CurrentChunk()
{
MxStreamChunk* chunk = NULL;
if (m_pendingChunkCursor)
if (m_pendingChunkCursor) {
m_pendingChunkCursor->First(chunk);
}
return chunk;
}
@@ -116,10 +126,12 @@ void MxDSSubscriber::DestroyChunk(MxStreamChunk* p_chunk)
if (p_chunk) {
if (m_consumedChunkCursor->Find(p_chunk)) {
m_consumedChunkCursor->Detach();
if (p_chunk)
if (p_chunk) {
delete p_chunk;
}
}
else if (p_chunk->GetFlags() & MxDSChunk::c_bit1 && p_chunk)
else if (p_chunk->GetFlags() & MxDSChunk::c_bit1 && p_chunk) {
delete p_chunk;
}
}
}

View File

@@ -72,8 +72,9 @@ MxU16 MXIOINFO::Close(MxLong p_unused)
_lclose((HFILE) m_info.hmmio);
m_info.hmmio = 0;
if (m_info.dwFlags & MMIO_ALLOCBUF)
if (m_info.dwFlags & MMIO_ALLOCBUF) {
delete[] m_info.pchBuffer;
}
m_info.pchEndWrite = 0;
m_info.pchEndRead = 0;
@@ -95,8 +96,9 @@ MxLong MXIOINFO::Read(void* p_buf, MxLong p_len)
while (p_len > 0) {
if (bytesLeft > 0) {
if (p_len < bytesLeft)
if (p_len < bytesLeft) {
bytesLeft = p_len;
}
memcpy(p_buf, m_info.pchNext, bytesLeft);
p_len -= bytesLeft;
@@ -105,12 +107,14 @@ MxLong MXIOINFO::Read(void* p_buf, MxLong p_len)
bytesRead += bytesLeft;
}
if (p_len <= 0 || Advance(0))
if (p_len <= 0 || Advance(0)) {
break;
}
bytesLeft = m_info.pchEndRead - m_info.pchNext;
if (bytesLeft <= 0)
if (bytesLeft <= 0) {
break;
}
}
}
else if (m_info.hmmio && p_len > 0) {
@@ -381,8 +385,9 @@ MxU16 MXIOINFO::Descend(MMCKINFO* p_chunkInfo, const MMCKINFO* p_parentInfo, MxU
{
MxU16 result = 0;
if (!p_chunkInfo)
if (!p_chunkInfo) {
return MMIOERR_BASE; // ?
}
if (!p_descend) {
p_chunkInfo->dwFlags = 0;
@@ -406,8 +411,9 @@ MxU16 MXIOINFO::Descend(MMCKINFO* p_chunkInfo, const MMCKINFO* p_parentInfo, MxU
else {
MxULong ofs = MAXLONG;
if (p_parentInfo)
if (p_parentInfo) {
ofs = p_parentInfo->cksize + p_parentInfo->dwDataOffset;
}
BOOL running = TRUE;
BOOL readOk = FALSE;
@@ -452,8 +458,9 @@ MxU16 MXIOINFO::Descend(MMCKINFO* p_chunkInfo, const MMCKINFO* p_parentInfo, MxU
}
}
if (!result)
if (!result) {
memcpy(p_chunkInfo, &tmp, sizeof(MMCKINFO));
}
}
return result;

View File

@@ -71,8 +71,9 @@ MxResult MxRAMStreamProvider::SetResourceToGet(MxStreamController* p_resource)
path = MxString(MxOmni::GetCD()) + p_resource->GetAtom().GetInternal() + ".si";
m_pFile->SetFileName(path.GetData());
if (m_pFile->Open(0) != 0)
if (m_pFile->Open(0) != 0) {
goto done;
}
}
m_fileSize = m_pFile->CalcFileSize();
@@ -131,23 +132,27 @@ MxU32 ReadData(MxU8* p_buffer, MxU32 p_size)
MxDSBuffer::Append(data2, data3);
continue;
}
else
else {
*MxStreamChunk::IntoFlags(data2) &= ~MxDSChunk::c_split;
}
}
data2 += MxDSChunk::Size(*MxDSChunk::IntoLength(data2));
memcpy(data2, data3, MxDSChunk::Size(*psize));
if (*MxStreamChunk::IntoObjectId(data2) == id &&
(*MxStreamChunk::IntoFlags(data2) & MxDSChunk::c_end))
(*MxStreamChunk::IntoFlags(data2) & MxDSChunk::c_end)) {
break;
}
}
else
else {
data++;
}
}
}
else
else {
data++;
}
} while (data < end);
}

View File

@@ -45,12 +45,14 @@ MxStreamController::~MxStreamController()
MxAutoLocker lock(&m_criticalSection);
MxDSSubscriber* subscriber;
while (m_subscriberList.PopFront(subscriber))
while (m_subscriberList.PopFront(subscriber)) {
delete subscriber;
}
MxDSAction* action;
while (m_unk0x3c.PopFront(action))
while (m_unk0x3c.PopFront(action)) {
delete action;
}
if (m_provider) {
MxStreamProvider* provider = m_provider;
@@ -71,8 +73,9 @@ MxStreamController::~MxStreamController()
m_unk0x2c = NULL;
}
while (m_unk0x54.PopFront(action))
while (m_unk0x54.PopFront(action)) {
delete action;
}
}
// FUNCTION: LEGO1 0x100c1520
@@ -109,13 +112,16 @@ MxResult MxStreamController::VTable0x20(MxDSAction* p_action)
MxS32 objectId = p_action->GetObjectId();
MxStreamProvider* provider = m_provider;
if ((MxS32) provider->GetLengthInDWords() > objectId)
if ((MxS32) provider->GetLengthInDWords() > objectId) {
offset = provider->GetBufferForDWords()[objectId];
}
if (offset)
if (offset) {
result = VTable0x2c(p_action, offset);
else
}
else {
result = FAILURE;
}
return result;
}
@@ -159,16 +165,18 @@ MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset)
for (MxStreamListMxDSAction::iterator it = m_unk0x54.begin(); it != m_unk0x54.end(); it++) {
MxDSAction* action = *it;
if (action->GetObjectId() == p_action->GetObjectId())
if (action->GetObjectId() == p_action->GetObjectId()) {
newUnknown24 = Max(newUnknown24, action->GetUnknown24());
}
}
if (newUnknown24 == -1) {
for (MxStreamListMxDSAction::iterator it = m_unk0x3c.begin(); it != m_unk0x3c.end(); it++) {
MxDSAction* action = *it;
if (action->GetObjectId() == p_action->GetObjectId())
if (action->GetObjectId() == p_action->GetObjectId()) {
newUnknown24 = Max(newUnknown24, action->GetUnknown24());
}
}
if (newUnknown24 == -1) {
@@ -176,8 +184,9 @@ MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset)
it++) {
MxDSSubscriber* subscriber = *it;
if (subscriber->GetObjectId() == p_action->GetObjectId())
if (subscriber->GetObjectId() == p_action->GetObjectId()) {
newUnknown24 = Max(newUnknown24, subscriber->GetUnknown48());
}
}
}
}
@@ -185,14 +194,16 @@ MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset)
p_action->SetUnknown24(newUnknown24 + 1);
}
else {
if (m_unk0x3c.Find(p_action, FALSE))
if (m_unk0x3c.Find(p_action, FALSE)) {
return FAILURE;
}
}
MxDSStreamingAction* streamingAction = new MxDSStreamingAction(*p_action, p_offset);
if (!streamingAction)
if (!streamingAction) {
return FAILURE;
}
MxU32 fileSize = m_provider->GetFileSize();
streamingAction->SetBufferOffset(fileSize * (p_offset / fileSize));
@@ -268,14 +279,16 @@ MxResult MxStreamController::FUN_100c1f00(MxDSAction* p_action)
MxU32 objectId = p_action->GetObjectId();
MxStreamChunk* chunk = new MxStreamChunk;
if (!chunk)
if (!chunk) {
return FAILURE;
}
chunk->SetFlags(MxDSChunk::c_bit3);
chunk->SetObjectId(objectId);
if (chunk->SendChunk(m_subscriberList, FALSE, p_action->GetUnknown24()) != SUCCESS)
if (chunk->SendChunk(m_subscriberList, FALSE, p_action->GetUnknown24()) != SUCCESS) {
delete chunk;
}
if (p_action->IsA("MxDSMultiAction")) {
MxDSActionList* actions = ((MxDSMultiAction*) p_action)->GetActionList();
@@ -283,8 +296,9 @@ MxResult MxStreamController::FUN_100c1f00(MxDSAction* p_action)
MxDSAction* action;
while (cursor.Next(action)) {
if (FUN_100c1f00(action) != SUCCESS)
if (FUN_100c1f00(action) != SUCCESS) {
return FAILURE;
}
}
}
@@ -300,8 +314,9 @@ MxNextActionDataStart* MxStreamController::FindNextActionDataStartFromStreamingA
// FUNCTION: LEGO1 0x100c20d0
MxBool MxStreamController::FUN_100c20d0(MxDSObject& p_obj)
{
if (m_subscriberList.Find(&p_obj))
if (m_subscriberList.Find(&p_obj)) {
return FALSE;
}
if (p_obj.IsA("MxDSMultiAction")) {
MxDSActionList* actions = ((MxDSMultiAction&) p_obj).GetActionList();
@@ -309,8 +324,9 @@ MxBool MxStreamController::FUN_100c20d0(MxDSObject& p_obj)
MxDSAction* action;
while (cursor.Next(action)) {
if (!FUN_100c20d0(*action))
if (!FUN_100c20d0(*action)) {
return FALSE;
}
}
}

View File

@@ -79,8 +79,9 @@ MxLong MxStreamer::Close(const char* p_name)
if (!p_name || !strcmp(p_name, c->GetAtom().GetInternal())) {
m_openStreams.erase(it);
if (c->FUN_100c20d0(ds))
if (c->FUN_100c20d0(ds)) {
delete c;
}
else {
#ifdef COMPAT_MODE
{
@@ -185,8 +186,9 @@ MxResult MxStreamer::DeleteObject(MxDSAction* p_dsAction)
MxBool MxStreamer::FUN_100b9b30(MxDSObject& p_dsObject)
{
MxStreamController* controller = GetOpenStream(p_dsObject.GetAtomId().GetInternal());
if (controller)
if (controller) {
return controller->FUN_100c20d0(p_dsObject);
}
return TRUE;
}
@@ -200,8 +202,9 @@ MxLong MxStreamer::Notify(MxParam& p_param)
MxStreamController* c = static_cast<MxStreamerNotification&>(p_param).GetController();
if (c->FUN_100c20d0(ds))
if (c->FUN_100c20d0(ds)) {
delete c;
}
else {
#ifdef COMPAT_MODE
{

View File

@@ -36,8 +36,9 @@ MxDSAction* MxStreamListMxDSAction::Find(MxDSAction* p_action, MxBool p_delete)
if (p_action->GetUnknown24() == -2 || p_action->GetUnknown24() == -3 ||
p_action->GetUnknown24() == (*it)->GetUnknown24()) {
found = *it;
if (p_action->GetUnknown24() != -3)
if (p_action->GetUnknown24() != -3) {
break;
}
}
}
}
@@ -53,8 +54,9 @@ MxDSAction* MxStreamListMxDSAction::Find(MxDSAction* p_action, MxBool p_delete)
MxNextActionDataStart* MxStreamListMxNextActionDataStart::Find(MxU32 p_id, MxS16 p_value)
{
for (iterator it = begin(); it != end(); it++) {
if (p_id == (*it)->GetObjectId() && p_value == (*it)->GetUnknown24())
if (p_id == (*it)->GetObjectId() && p_value == (*it)->GetUnknown24()) {
return *it;
}
}
return NULL;

View File

@@ -4,13 +4,15 @@
MxAutoLocker::MxAutoLocker(MxCriticalSection* p_criticalSection)
{
this->m_criticalSection = p_criticalSection;
if (this->m_criticalSection != 0)
if (this->m_criticalSection != 0) {
this->m_criticalSection->Enter();
}
}
// FUNCTION: LEGO1 0x100b8ef0
MxAutoLocker::~MxAutoLocker()
{
if (this->m_criticalSection != 0)
if (this->m_criticalSection != 0) {
this->m_criticalSection->Leave();
}
}

View File

@@ -15,8 +15,9 @@ MxSemaphore::MxSemaphore()
MxResult MxSemaphore::Init(MxU32 p_initialCount, MxU32 p_maxCount)
{
MxResult result = FAILURE;
if (m_hSemaphore = CreateSemaphoreA(NULL, p_initialCount, p_maxCount, NULL))
if ((m_hSemaphore = CreateSemaphoreA(NULL, p_initialCount, p_maxCount, NULL))) {
result = SUCCESS;
}
return result;
}

View File

@@ -51,8 +51,9 @@ MxThread::MxThread()
// FUNCTION: LEGO1 0x100bf5a0
MxThread::~MxThread()
{
if (m_hThread)
if (m_hThread) {
CloseHandle((HANDLE) m_hThread);
}
}
typedef unsigned(__stdcall* ThreadFunc)(void*);
@@ -62,9 +63,10 @@ MxResult MxThread::Start(MxS32 p_stack, MxS32 p_flag)
{
MxResult result = FAILURE;
if (m_semaphore.Init(0, 1) == SUCCESS) {
if (m_hThread =
_beginthreadex(NULL, p_stack << 2, (ThreadFunc) &MxThread::ThreadProc, this, p_flag, &m_threadId))
if ((m_hThread =
_beginthreadex(NULL, p_stack << 2, (ThreadFunc) &MxThread::ThreadProc, this, p_flag, &m_threadId))) {
result = SUCCESS;
}
}
return result;
}

View File

@@ -25,12 +25,15 @@ MxBitmap::MxBitmap()
// FUNCTION: LEGO1 0x100bca10
MxBitmap::~MxBitmap()
{
if (this->m_info)
if (this->m_info) {
delete m_info;
if (this->m_data)
}
if (this->m_data) {
delete m_data;
if (this->m_palette)
}
if (this->m_palette) {
delete m_palette;
}
}
// FUNCTION: LEGO1 0x100bcaa0
@@ -152,11 +155,13 @@ MxLong MxBitmap::Read(const char* p_filename)
HANDLE handle =
CreateFileA(p_filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (handle != INVALID_HANDLE_VALUE && !LoadFile(handle))
if (handle != INVALID_HANDLE_VALUE && !LoadFile(handle)) {
result = SUCCESS;
}
if (handle)
if (handle) {
CloseHandle(handle);
}
return result;
}
@@ -280,8 +285,9 @@ void MxBitmap::BitBltTransparent(
for (MxS32 h = 0; h < p_height; h++) {
for (MxS32 w = 0; w < p_width; w++) {
if (*srcStart)
if (*srcStart) {
*dstStart = *srcStart;
}
srcStart++;
dstStart++;
}
@@ -302,15 +308,17 @@ MxPalette* MxBitmap::CreatePalette()
case FALSE:
palette = new MxPalette(this->m_paletteData);
if (!palette)
if (!palette) {
goto done;
}
break;
case TRUE:
palette = this->m_palette->Clone();
if (!palette)
if (!palette) {
goto done;
}
break;
default:
@@ -361,8 +369,9 @@ MxResult MxBitmap::SetBitDepth(MxBool p_isHighColor)
switch (p_isHighColor) {
case FALSE:
ImportColorsToPalette(m_paletteData, m_palette);
if (m_palette)
if (m_palette) {
delete m_palette;
}
m_palette = NULL;
break;
@@ -370,8 +379,9 @@ MxResult MxBitmap::SetBitDepth(MxBool p_isHighColor)
pal = NULL;
pal = new MxPalette(m_paletteData);
if (!pal)
if (!pal) {
goto done;
}
m_palette = pal;
@@ -392,8 +402,9 @@ MxResult MxBitmap::SetBitDepth(MxBool p_isHighColor)
done:
// If we were unsuccessful overall but did manage to alloc
// the MxPalette, free it.
if (ret && pal)
if (ret && pal) {
delete pal;
}
return ret;
}
@@ -438,13 +449,15 @@ MxResult MxBitmap::ImportColorsToPalette(RGBQUAD* p_rgbquad, MxPalette* p_palett
PALETTEENTRY entries[256];
if (p_palette) {
if (p_palette->GetEntries(entries))
if (p_palette->GetEntries(entries)) {
goto done;
}
}
else {
MxPalette palette;
if (palette.GetEntries(entries))
if (palette.GetEntries(entries)) {
goto done;
}
}
MxS32 i;

View File

@@ -81,8 +81,9 @@ MxU8 MxDisplaySurface::CountTotalBitsSetTo1(MxU32 p_param)
{
MxU8 count = 0;
for (; p_param; p_param >>= 1)
for (; p_param; p_param >>= 1) {
count += ((MxU8) p_param & 1);
}
return count;
}
@@ -92,8 +93,9 @@ MxU8 MxDisplaySurface::CountContiguousBitsSetTo1(MxU32 p_param)
{
MxU8 count = 0;
for (; (p_param & 1) == 0; p_param >>= 1)
for (; (p_param & 1) == 0; p_param >>= 1) {
count++;
}
return count;
}
@@ -117,8 +119,9 @@ MxResult MxDisplaySurface::Init(
memset(&this->m_surfaceDesc, 0, sizeof(this->m_surfaceDesc));
this->m_surfaceDesc.dwSize = sizeof(this->m_surfaceDesc);
if (this->m_ddSurface2->GetSurfaceDesc(&this->m_surfaceDesc))
if (this->m_ddSurface2->GetSurfaceDesc(&this->m_surfaceDesc)) {
result = FAILURE;
}
return result;
}
@@ -134,8 +137,9 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
this->m_initialized = TRUE;
this->m_videoParam = p_videoParam;
if (!this->m_videoParam.Flags().GetFullScreen())
if (!this->m_videoParam.Flags().GetFullScreen()) {
this->m_videoParam.Flags().SetFlipSurfaces(FALSE);
}
if (!this->m_videoParam.Flags().GetFlipSurfaces()) {
this->m_videoParam.SetBackBuffers(1);
@@ -143,10 +147,12 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
else {
MxU32 backBuffers = this->m_videoParam.GetBackBuffers();
if (backBuffers < 1)
if (backBuffers < 1) {
this->m_videoParam.SetBackBuffers(1);
else if (backBuffers > 2)
}
else if (backBuffers > 2) {
this->m_videoParam.SetBackBuffers(2);
}
this->m_videoParam.Flags().SetBackBuffers(TRUE);
}
@@ -155,20 +161,23 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
MxS32 width = this->m_videoParam.GetRect().GetWidth();
MxS32 height = this->m_videoParam.GetRect().GetHeight();
if (lpDirectDraw->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN))
if (lpDirectDraw->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)) {
goto done;
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
if (lpDirectDraw->GetDisplayMode(&ddsd))
if (lpDirectDraw->GetDisplayMode(&ddsd)) {
goto done;
}
MxS32 bitdepth = !this->m_videoParam.Flags().Get16Bit() ? 8 : 16;
if (ddsd.dwWidth != width || ddsd.dwHeight != height || ddsd.ddpfPixelFormat.dwRGBBitCount != bitdepth) {
if (lpDirectDraw->SetDisplayMode(width, height, bitdepth))
if (lpDirectDraw->SetDisplayMode(width, height, bitdepth)) {
goto done;
}
}
}
@@ -179,13 +188,15 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
if (lpDirectDraw->CreateSurface(&ddsd, &this->m_ddSurface1, NULL))
if (lpDirectDraw->CreateSurface(&ddsd, &this->m_ddSurface1, NULL)) {
goto done;
}
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (this->m_ddSurface1->GetAttachedSurface(&ddsd.ddsCaps, &this->m_ddSurface2))
if (this->m_ddSurface1->GetAttachedSurface(&ddsd.ddsCaps, &this->m_ddSurface2)) {
goto done;
}
}
else {
memset(&ddsd, 0, sizeof(ddsd));
@@ -193,8 +204,9 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (lpDirectDraw->CreateSurface(&ddsd, &this->m_ddSurface1, NULL))
if (lpDirectDraw->CreateSurface(&ddsd, &this->m_ddSurface1, NULL)) {
goto done;
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
@@ -203,11 +215,13 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
ddsd.dwHeight = this->m_videoParam.GetRect().GetHeight();
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE | DDSCAPS_OFFSCREENPLAIN;
if (!this->m_videoParam.Flags().GetBackBuffers())
if (!this->m_videoParam.Flags().GetBackBuffers()) {
ddsd.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
}
if (lpDirectDraw->CreateSurface(&ddsd, &this->m_ddSurface2, NULL))
if (lpDirectDraw->CreateSurface(&ddsd, &this->m_ddSurface2, NULL)) {
goto done;
}
}
memset(&this->m_surfaceDesc, 0, sizeof(this->m_surfaceDesc));
@@ -215,8 +229,9 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
if (!this->m_ddSurface2->GetSurfaceDesc(&this->m_surfaceDesc)) {
if (!lpDirectDraw->CreateClipper(0, &this->m_ddClipper, NULL) && !this->m_ddClipper->SetHWnd(0, hWnd) &&
!this->m_ddSurface1->SetClipper(this->m_ddClipper))
!this->m_ddSurface1->SetClipper(this->m_ddClipper)) {
result = SUCCESS;
}
}
done:
@@ -227,18 +242,22 @@ done:
void MxDisplaySurface::Destroy()
{
if (this->m_initialized) {
if (this->m_ddSurface2)
if (this->m_ddSurface2) {
this->m_ddSurface2->Release();
}
if (this->m_ddSurface1)
if (this->m_ddSurface1) {
this->m_ddSurface1->Release();
}
if (this->m_ddClipper)
if (this->m_ddClipper) {
this->m_ddClipper->Release();
}
}
if (this->m_16bitPal)
if (this->m_16bitPal) {
delete[] this->m_16bitPal;
}
this->Init();
}
@@ -273,8 +292,9 @@ void MxDisplaySurface::SetPalette(MxPalette* p_palette)
}
if (m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount == 16) {
if (!m_16bitPal)
if (!m_16bitPal) {
m_16bitPal = new MxU16[256];
}
PALETTEENTRY palette[256];
p_palette->GetEntries(palette);
@@ -287,9 +307,9 @@ void MxDisplaySurface::SetPalette(MxPalette* p_palette)
MxU8 totalBitsBlue = CountTotalBitsSetTo1(m_surfaceDesc.ddpfPixelFormat.dwBBitMask);
for (MxS32 i = 0; i < 256; i++) {
m_16bitPal[i] = (((palette[i].peRed >> (8 - totalBitsRed & 0x1f)) << (contiguousBitsRed & 0x1f))) |
(((palette[i].peGreen >> (8 - totalBitsGreen & 0x1f)) << (contiguousBitsGreen & 0x1f))) |
(((palette[i].peBlue >> (8 - totalBitsBlue & 0x1f)) << (contiguousBitsBlue & 0x1f)));
m_16bitPal[i] = (((palette[i].peRed >> ((8 - totalBitsRed) & 0x1f)) << (contiguousBitsRed & 0x1f))) |
(((palette[i].peGreen >> ((8 - totalBitsGreen) & 0x1f)) << (contiguousBitsGreen & 0x1f))) |
(((palette[i].peBlue >> ((8 - totalBitsBlue) & 0x1f)) << (contiguousBitsBlue & 0x1f)));
}
}
}
@@ -528,8 +548,9 @@ void MxDisplaySurface::Display(MxS32 p_left, MxS32 p_top, MxS32 p_left2, MxS32 p
// FUNCTION: LEGO1 0x100bbc10
void MxDisplaySurface::GetDC(HDC* p_hdc)
{
if (this->m_ddSurface2 && !this->m_ddSurface2->GetDC(p_hdc))
if (this->m_ddSurface2 && !this->m_ddSurface2->GetDC(p_hdc)) {
return;
}
*p_hdc = NULL;
}
@@ -537,8 +558,9 @@ void MxDisplaySurface::GetDC(HDC* p_hdc)
// FUNCTION: LEGO1 0x100bbc40
void MxDisplaySurface::ReleaseDC(HDC p_hdc)
{
if (this->m_ddSurface2 && p_hdc)
if (this->m_ddSurface2 && p_hdc) {
this->m_ddSurface2->ReleaseDC(p_hdc);
}
}
// FUNCTION: LEGO1 0x100bbc60
@@ -557,8 +579,9 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
if (draw->GetDisplayMode(&ddsd))
if (draw->GetDisplayMode(&ddsd)) {
return NULL;
}
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwWidth = p_bitmap->GetBmiWidth();
@@ -579,8 +602,9 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
surface = NULL;
}
}
else
else {
surface = NULL;
}
}
if (surface) {
@@ -604,8 +628,9 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
// TODO: Probably p_bitmap->GetAdjustedStride()
MxS32 rowSeek = p_bitmap->GetBmiStride();
if (p_bitmap->GetBmiHeader()->biCompression != BI_RGB_TOPDOWN && p_bitmap->GetBmiHeight() >= 0)
if (p_bitmap->GetBmiHeader()->biCompression != BI_RGB_TOPDOWN && p_bitmap->GetBmiHeight() >= 0) {
rowSeek = -rowSeek;
}
MxLong newPitch = ddsd.lPitch;
switch (ddsd.ddpfPixelFormat.dwRGBBitCount) {
@@ -714,15 +739,17 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface()
ddsd.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK)
if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) {
goto done;
}
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
if (newSurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL) != DD_OK)
if (newSurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL) != DD_OK) {
goto done;
}
else {
MxU16* surface = (MxU16*) ddsd.lpSurface;
MxLong pitch = ddsd.lPitch;
@@ -732,10 +759,12 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface()
MxU16* surface2 = surface;
for (MxS32 y = 0; y < 16; y++) {
if ((y > 10 || x) && (x > 10 || y) && x + y != 10) {
if (x + y > 10)
if (x + y > 10) {
*surface2 = 31775;
else
}
else {
*surface2 = -1;
}
}
else {
*surface2 = 0;

View File

@@ -35,8 +35,9 @@ void MxFlcPresenter::LoadHeader(MxStreamChunk* p_chunk)
// FUNCTION: LEGO1 0x100b34d0
void MxFlcPresenter::CreateBitmap()
{
if (m_bitmap)
if (m_bitmap) {
delete m_bitmap;
}
m_bitmap = new MxBitmap;
m_bitmap->SetSize(m_flcHeader->width, m_flcHeader->height, NULL, FALSE);
@@ -62,8 +63,9 @@ void MxFlcPresenter::LoadFrame(MxStreamChunk* p_chunk)
&decodedColorMap
);
if (((MxDSMediaAction*) m_action)->GetPaletteManagement() && decodedColorMap)
if (((MxDSMediaAction*) m_action)->GetPaletteManagement() && decodedColorMap) {
RealizePalette();
}
for (MxS32 i = 0; i < rectCount; i++) {
MxRect32 rect(rects[i]);

View File

@@ -31,8 +31,9 @@ void MxLoopingFlcPresenter::Destroy(MxBool p_fromDestructor)
Init();
m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxFlcPresenter::Destroy(FALSE);
}
}
// FUNCTION: LEGO1 0x100b4470
@@ -40,8 +41,9 @@ void MxLoopingFlcPresenter::NextFrame()
{
MxStreamChunk* chunk = NextChunk();
if (chunk->GetFlags() & MxDSChunk::c_end)
if (chunk->GetFlags() & MxDSChunk::c_end) {
ProgressTickleState(e_repeating);
}
else {
LoadFrame(chunk);
LoopChunk(chunk);
@@ -54,8 +56,9 @@ void MxLoopingFlcPresenter::NextFrame()
// FUNCTION: LEGO1 0x100b44c0
void MxLoopingFlcPresenter::VTable0x88()
{
if (m_action->GetDuration() < m_elapsedDuration)
if (m_action->GetDuration() < m_elapsedDuration) {
ProgressTickleState(e_unk5);
}
else {
MxStreamChunk* chunk;
m_loopingChunkCursor->Current(chunk);
@@ -81,8 +84,9 @@ void MxLoopingFlcPresenter::RepeatingTickle()
time += m_flcHeader->speed;
cursor.Reset();
while (cursor.Next(chunk))
while (cursor.Next(chunk)) {
chunk->SetTime(chunk->GetTime() + time);
}
m_loopingChunkCursor->Next();
}
@@ -90,15 +94,17 @@ void MxLoopingFlcPresenter::RepeatingTickle()
MxStreamChunk* chunk;
m_loopingChunkCursor->Current(chunk);
if (m_action->GetElapsedTime() < chunk->GetTime())
if (m_action->GetElapsedTime() < chunk->GetTime()) {
break;
}
VTable0x88();
m_loopingChunkCursor->Next(chunk);
if (m_currentTickleState != e_repeating)
if (m_currentTickleState != e_repeating) {
break;
}
}
}
@@ -114,8 +120,9 @@ MxResult MxLoopingFlcPresenter::AddToManager()
result = SUCCESS;
}
if (locked)
if (locked) {
m_criticalSection.Leave();
}
return result;
}

View File

@@ -32,8 +32,9 @@ void MxLoopingSmkPresenter::Destroy(MxBool p_fromDestructor)
Init();
m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxSmkPresenter::Destroy();
}
}
// FUNCTION: LEGO1 0x100b4a00
@@ -51,8 +52,9 @@ void MxLoopingSmkPresenter::NextFrame()
{
MxStreamChunk* chunk = NextChunk();
if (chunk->GetFlags() & MxDSChunk::c_end)
if (chunk->GetFlags() & MxDSChunk::c_end) {
ProgressTickleState(e_repeating);
}
else {
LoadFrame(chunk);
LoopChunk(chunk);
@@ -65,8 +67,9 @@ void MxLoopingSmkPresenter::NextFrame()
// FUNCTION: LEGO1 0x100b4a90
void MxLoopingSmkPresenter::VTable0x8c()
{
if (m_action->GetDuration() < m_elapsedDuration)
if (m_action->GetDuration() < m_elapsedDuration) {
ProgressTickleState(e_unk5);
}
else {
MxStreamChunk* chunk;
m_loopingChunkCursor->Current(chunk);
@@ -92,8 +95,9 @@ void MxLoopingSmkPresenter::RepeatingTickle()
time += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
cursor.Reset();
while (cursor.Next(chunk))
while (cursor.Next(chunk)) {
chunk->SetTime(chunk->GetTime() + time);
}
m_loopingChunkCursor->Next();
}
@@ -101,15 +105,17 @@ void MxLoopingSmkPresenter::RepeatingTickle()
MxStreamChunk* chunk;
m_loopingChunkCursor->Current(chunk);
if (m_action->GetElapsedTime() < chunk->GetTime())
if (m_action->GetElapsedTime() < chunk->GetTime()) {
break;
}
VTable0x8c();
m_loopingChunkCursor->Next(chunk);
if (m_currentTickleState != e_repeating)
if (m_currentTickleState != e_repeating) {
break;
}
}
}

View File

@@ -110,18 +110,23 @@ LPDIRECTDRAWPALETTE MxPalette::CreateNativePalette()
{
MxS32 i;
if (this->m_palette == NULL) {
for (i = 0; i < 10; i++)
for (i = 0; i < 10; i++) {
this->m_entries[i].peFlags = 0x80;
for (i = 10; i < 136; i++)
}
for (i = 10; i < 136; i++) {
this->m_entries[i].peFlags = 0x44;
for (i = 136; i < 140; i++)
}
for (i = 136; i < 140; i++) {
this->m_entries[i].peFlags = 0x84;
}
this->m_entries[140].peFlags = 0x84;
this->m_entries[141].peFlags = 0x44;
for (i = 142; i < 246; i++)
for (i = 142; i < 246; i++) {
this->m_entries[i].peFlags = 0x84;
for (i = 246; i < 256; i++)
}
for (i = 246; i < 256; i++) {
this->m_entries[i].peFlags = 0x80;
}
if (MVideoManager() && MVideoManager()->GetDirectDraw()) {
MVideoManager()->GetDirectDraw()->CreatePalette(4, this->m_entries, &this->m_palette, NULL);
@@ -154,8 +159,9 @@ MxResult MxPalette::SetEntries(LPPALETTEENTRY p_entries)
MxResult status = SUCCESS;
if (this->m_palette) {
for (i = 0; i < 10; i++)
for (i = 0; i < 10; i++) {
this->m_entries[i].peFlags = 0x80;
}
for (i = 10; i < 136; i++) {
this->m_entries[i].peFlags = 68;
this->m_entries[i].peRed = p_entries[i].peRed;
@@ -186,11 +192,13 @@ MxResult MxPalette::SetEntries(LPPALETTEENTRY p_entries)
this->m_entries[i].peBlue = p_entries[i].peBlue;
}
for (i = 246; i < 256; i++)
for (i = 246; i < 256; i++) {
this->m_entries[i].peFlags = 0x80;
}
if (this->m_palette->SetEntries(0, 0, 256, this->m_entries))
if (this->m_palette->SetEntries(0, 0, 256, this->m_entries)) {
status = FAILURE;
}
}
return status;
@@ -222,12 +230,15 @@ void MxPalette::Detach()
MxBool MxPalette::operator==(MxPalette& p_other)
{
for (MxS32 i = 0; i < 256; i++) {
if (this->m_entries[i].peRed != p_other.m_entries[i].peRed)
if (this->m_entries[i].peRed != p_other.m_entries[i].peRed) {
return FALSE;
if (this->m_entries[i].peGreen != p_other.m_entries[i].peGreen)
}
if (this->m_entries[i].peGreen != p_other.m_entries[i].peGreen) {
return FALSE;
if (this->m_entries[i].peBlue != p_other.m_entries[i].peBlue)
}
if (this->m_entries[i].peBlue != p_other.m_entries[i].peBlue) {
return FALSE;
}
}
return TRUE;
}

View File

@@ -22,8 +22,9 @@ MxBool MxRegion::VTable0x20()
// FUNCTION: LEGO1 0x100c3690
MxRegion::~MxRegion()
{
if (m_list)
if (m_list) {
delete m_list;
}
}
// FUNCTION: LEGO1 0x100c3700
@@ -88,17 +89,20 @@ void MxRegion::VTable0x18(MxRect32& p_rect)
// FUNCTION: LEGO1 0x100c3e20
MxBool MxRegion::VTable0x1c(MxRect32& p_rect)
{
if (!m_rect.IntersectsWith(p_rect))
if (!m_rect.IntersectsWith(p_rect)) {
return FALSE;
}
MxRegionTopBottomListCursor cursor(m_list);
MxRegionTopBottom* topBottom;
while (cursor.Next(topBottom)) {
if (topBottom->GetTop() >= p_rect.GetBottom())
if (topBottom->GetTop() >= p_rect.GetBottom()) {
return FALSE;
if (topBottom->GetBottom() > p_rect.GetTop() && topBottom->FUN_100c57b0(p_rect))
}
if (topBottom->GetBottom() > p_rect.GetTop() && topBottom->FUN_100c57b0(p_rect)) {
return TRUE;
}
}
return FALSE;
@@ -130,27 +134,31 @@ void MxRegionTopBottom::FUN_100c5280(MxS32 p_left, MxS32 p_right)
MxRegionLeftRightListCursor b(m_leftRightList);
MxRegionLeftRight* leftRight;
while (a.Next(leftRight) && leftRight->GetRight() < p_left)
while (a.Next(leftRight) && leftRight->GetRight() < p_left) {
;
}
if (!a.HasMatch()) {
MxRegionLeftRight* copy = new MxRegionLeftRight(p_left, p_right);
m_leftRightList->Append(copy);
}
else {
if (p_left > leftRight->GetLeft())
if (p_left > leftRight->GetLeft()) {
p_left = leftRight->GetLeft();
}
while (leftRight->GetLeft() < p_right) {
if (p_right < leftRight->GetRight())
if (p_right < leftRight->GetRight()) {
p_right = leftRight->GetRight();
}
b = a;
b.Next();
a.Destroy();
if (!b.Current(leftRight))
if (!b.Current(leftRight)) {
break;
}
a = b;
}
@@ -174,8 +182,9 @@ MxRegionTopBottom* MxRegionTopBottom::Clone()
MxRegionLeftRightListCursor cursor(m_leftRightList);
MxRegionLeftRight* leftRight;
while (cursor.Next(leftRight))
while (cursor.Next(leftRight)) {
clone->m_leftRightList->Append(leftRight->Clone());
}
return clone;
}
@@ -187,10 +196,12 @@ MxBool MxRegionTopBottom::FUN_100c57b0(MxRect32& p_rect)
MxRegionLeftRight* leftRight;
while (cursor.Next(leftRight)) {
if (p_rect.GetRight() <= leftRight->GetLeft())
if (p_rect.GetRight() <= leftRight->GetLeft()) {
return FALSE;
if (leftRight->GetRight() > p_rect.GetLeft())
}
if (leftRight->GetRight() > p_rect.GetLeft()) {
return TRUE;
}
}
return FALSE;

View File

@@ -14,14 +14,17 @@ MxRegionCursor::MxRegionCursor(MxRegion* p_region)
// FUNCTION: LEGO1 0x100c40b0
MxRegionCursor::~MxRegionCursor()
{
if (m_rect)
if (m_rect) {
delete m_rect;
}
if (m_topBottomCursor)
if (m_topBottomCursor) {
delete m_topBottomCursor;
}
if (m_leftRightCursor)
if (m_leftRightCursor) {
delete m_leftRightCursor;
}
}
// FUNCTION: LEGO1 0x100c4140
@@ -38,8 +41,9 @@ MxRect32* MxRegionCursor::VTable0x18()
UpdateRect(leftRight->GetLeft(), topBottom->GetTop(), leftRight->GetRight(), topBottom->GetBottom());
}
else
else {
Reset();
}
return m_rect;
}
@@ -58,8 +62,9 @@ MxRect32* MxRegionCursor::VTable0x20()
UpdateRect(leftRight->GetLeft(), topBottom->GetTop(), leftRight->GetRight(), topBottom->GetBottom());
}
else
else {
Reset();
}
return m_rect;
}
@@ -144,11 +149,13 @@ MxRect32* MxRegionCursor::VTable0x24(MxRect32& p_rect)
UpdateRect(leftRight->GetLeft(), topBottom->GetTop(), leftRight->GetRight(), topBottom->GetBottom());
m_rect->Intersect(p_rect);
}
else
else {
FUN_100c4a20(p_rect);
}
}
else
else {
FUN_100c4a20(p_rect);
}
return m_rect;
}
@@ -167,11 +174,13 @@ MxRect32* MxRegionCursor::VTable0x2c(MxRect32& p_rect)
UpdateRect(leftRight->GetLeft(), topBottom->GetTop(), leftRight->GetRight(), topBottom->GetBottom());
m_rect->Intersect(p_rect);
}
else
else {
FUN_100c4b50(p_rect);
}
}
else
else {
FUN_100c4b50(p_rect);
}
return m_rect;
}
@@ -195,8 +204,9 @@ void MxRegionCursor::Reset()
// FUNCTION: LEGO1 0x100c46c0
void MxRegionCursor::FUN_100c46c0(MxRegionLeftRightList& p_leftRightList)
{
if (m_leftRightCursor)
if (m_leftRightCursor) {
delete m_leftRightCursor;
}
m_leftRightCursor = new MxRegionLeftRightListCursor(&p_leftRightList);
}
@@ -204,8 +214,9 @@ void MxRegionCursor::FUN_100c46c0(MxRegionLeftRightList& p_leftRightList)
// FUNCTION: LEGO1 0x100c4980
void MxRegionCursor::UpdateRect(MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom)
{
if (!m_rect)
if (!m_rect) {
m_rect = new MxRect32;
}
m_rect->SetLeft(p_left);
m_rect->SetTop(p_top);
@@ -228,8 +239,9 @@ void MxRegionCursor::FUN_100c4a20(MxRect32& p_rect)
MxRegionLeftRight* leftRight;
while (m_leftRightCursor->Next(leftRight)) {
if (p_rect.GetRight() <= leftRight->GetLeft())
if (p_rect.GetRight() <= leftRight->GetLeft()) {
break;
}
if (p_rect.GetLeft() < leftRight->GetRight()) {
UpdateRect(
@@ -263,8 +275,9 @@ void MxRegionCursor::FUN_100c4b50(MxRect32& p_rect)
MxRegionLeftRight* leftRight;
while (m_leftRightCursor->Prev(leftRight)) {
if (leftRight->GetRight() <= p_rect.GetLeft())
if (leftRight->GetRight() <= p_rect.GetLeft()) {
break;
}
if (leftRight->GetLeft() < p_rect.GetRight()) {
UpdateRect(

View File

@@ -40,8 +40,9 @@ MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack)
// TODO
for (MxU32 i = 0; i < FRAME_COUNT(p_mxSmack); i++) {
if (p_mxSmack->m_maxFrameSize < frameSizes[i])
if (p_mxSmack->m_maxFrameSize < frameSizes[i]) {
p_mxSmack->m_maxFrameSize = frameSizes[i];
}
}
frameTypes = new MxU8[FRAME_COUNT(p_mxSmack)];
@@ -54,8 +55,9 @@ MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack)
p_data += FRAME_COUNT(p_mxSmack);
MxU32 treeSize = p_mxSmack->m_smackTag.tablesize + 0x1000;
if (treeSize <= 0x2000)
if (treeSize <= 0x2000) {
treeSize = 0x2000;
}
huffmanTrees = new MxU8[treeSize];
@@ -127,16 +129,21 @@ MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack)
// FUNCTION: LEGO1 0x100c5d40
void MxSmack::Destroy(MxSmack* p_mxSmack)
{
if (p_mxSmack->m_frameSizes)
if (p_mxSmack->m_frameSizes) {
delete[] p_mxSmack->m_frameSizes;
if (p_mxSmack->m_frameTypes)
}
if (p_mxSmack->m_frameTypes) {
delete[] p_mxSmack->m_frameTypes;
if (p_mxSmack->m_huffmanTrees)
}
if (p_mxSmack->m_huffmanTrees) {
delete[] p_mxSmack->m_huffmanTrees;
if (p_mxSmack->m_huffmanTables)
}
if (p_mxSmack->m_huffmanTables) {
delete[] p_mxSmack->m_huffmanTables;
if (p_mxSmack->m_unk0x6b4)
}
if (p_mxSmack->m_unk0x6b4) {
delete[] p_mxSmack->m_unk0x6b4;
}
}
// This should be refactored to somewhere else
@@ -223,12 +230,14 @@ MxBool MxSmack::GetRect(MxU8* p_unk0x6b4, MxU16* p_und, u32* p_smackRect, MxRect
{
u32 left, bottom, top, right;
if (!*p_und)
if (!*p_und) {
return FALSE;
}
if (*p_und == 1) {
if (!SmackGetRect(p_unk0x6b4, p_smackRect))
if (!SmackGetRect(p_unk0x6b4, p_smackRect)) {
return FALSE;
}
*p_und = 2;
}
@@ -238,10 +247,12 @@ MxBool MxSmack::GetRect(MxU8* p_unk0x6b4, MxU16* p_und, u32* p_smackRect, MxRect
bottom = p_smackRect[3] + p_smackRect[1];
while (SmackGetRect(p_unk0x6b4, p_smackRect)) {
if (left > p_smackRect[0])
if (left > p_smackRect[0]) {
left = p_smackRect[0];
if (right < p_smackRect[0] + p_smackRect[2])
}
if (right < p_smackRect[0] + p_smackRect[2]) {
right = p_smackRect[0] + p_smackRect[2];
}
bottom = p_smackRect[1] + p_smackRect[3];
}

View File

@@ -51,8 +51,9 @@ void MxSmkPresenter::LoadHeader(MxStreamChunk* p_chunk)
// FUNCTION: LEGO1 0x100b3960
void MxSmkPresenter::CreateBitmap()
{
if (m_bitmap)
if (m_bitmap) {
delete m_bitmap;
}
m_bitmap = new MxBitmap;
m_bitmap->SetSize(m_mxSmack.m_smackTag.Width, m_mxSmack.m_smackTag.Height, NULL, FALSE);
@@ -72,8 +73,9 @@ void MxSmkPresenter::LoadFrame(MxStreamChunk* p_chunk)
MxRectList list(TRUE);
MxSmack::LoadFrame(bitmapInfo, bitmapData, &m_mxSmack, chunkData, paletteChanged, &list);
if (((MxDSMediaAction*) m_action)->GetPaletteManagement() && paletteChanged)
if (((MxDSMediaAction*) m_action)->GetPaletteManagement() && paletteChanged) {
RealizePalette();
}
MxRect32 invalidateRect;
MxRectListCursor cursor(&list);
@@ -91,8 +93,9 @@ void MxSmkPresenter::VTable0x88()
{
if ((m_mxSmack.m_smackTag.SmackerType & 1) != 0) {
MxU32 und = (m_currentFrame % m_mxSmack.m_smackTag.Frames);
if (1 < m_currentFrame && und == 1)
if (1 < m_currentFrame && und == 1) {
m_currentFrame = 1;
}
}
else {
if (m_mxSmack.m_smackTag.Frames == m_currentFrame) {

View File

@@ -19,21 +19,24 @@ void MxStillPresenter::Destroy(MxBool p_fromDestructor)
{
m_criticalSection.Enter();
if (m_bitmapInfo)
if (m_bitmapInfo) {
delete m_bitmapInfo;
}
m_bitmapInfo = NULL;
m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxVideoPresenter::Destroy(FALSE);
}
}
// FUNCTION: LEGO1 0x100b9cc0
void MxStillPresenter::LoadHeader(MxStreamChunk* p_chunk)
{
if (m_bitmapInfo)
if (m_bitmapInfo) {
delete m_bitmapInfo;
}
MxU8* data = new MxU8[p_chunk->GetLength()];
m_bitmapInfo = (MxBITMAPINFO*) data;
@@ -43,8 +46,9 @@ void MxStillPresenter::LoadHeader(MxStreamChunk* p_chunk)
// FUNCTION: LEGO1 0x100b9d10
void MxStillPresenter::CreateBitmap()
{
if (m_bitmap)
if (m_bitmap) {
delete m_bitmap;
}
m_bitmap = new MxBitmap;
m_bitmap->ImportBitmapInfo(m_bitmapInfo);
@@ -90,10 +94,12 @@ void MxStillPresenter::LoadFrame(MxStreamChunk* p_chunk)
delete m_bitmap;
m_bitmap = NULL;
if (m_unk0x58 && und)
if (m_unk0x58 && und) {
SetBit2(TRUE);
else
}
else {
SetBit2(FALSE);
}
}
}
@@ -110,8 +116,9 @@ void MxStillPresenter::StartingTickle()
{
MxVideoPresenter::StartingTickle();
if (m_currentTickleState == e_streaming && ((MxDSMediaAction*) m_action)->GetPaletteManagement())
if (m_currentTickleState == e_streaming && ((MxDSMediaAction*) m_action)->GetPaletteManagement()) {
RealizePalette();
}
}
// FUNCTION: LEGO1 0x100b9f90
@@ -124,8 +131,9 @@ void MxStillPresenter::StreamingTickle()
NextFrame();
ProgressTickleState(e_repeating);
if (m_action->GetDuration() == -1 && m_compositePresenter)
if (m_action->GetDuration() == -1 && m_compositePresenter) {
m_compositePresenter->VTable0x60(this);
}
}
}
@@ -133,8 +141,9 @@ void MxStillPresenter::StreamingTickle()
void MxStillPresenter::RepeatingTickle()
{
if (m_action->GetDuration() != -1) {
if (m_action->GetElapsedTime() >= m_action->GetStartTime() + m_action->GetDuration())
if (m_action->GetElapsedTime() >= m_action->GetStartTime() + m_action->GetDuration()) {
ProgressTickleState(e_unk5);
}
}
}
@@ -185,13 +194,15 @@ void MxStillPresenter::ParseExtra()
{
MxPresenter::ParseExtra();
if (m_action->GetFlags() & MxDSAction::c_bit5)
if (m_action->GetFlags() & MxDSAction::c_bit5) {
SetBit3(TRUE);
}
MxU32 len = m_action->GetExtraLength();
if (len == 0)
if (len == 0) {
return;
}
len &= MAXWORD;
@@ -233,15 +244,18 @@ MxStillPresenter* MxStillPresenter::Clone()
if (m_bitmap) {
presenter->m_bitmap = new MxBitmap;
if (!presenter->m_bitmap || presenter->m_bitmap->ImportBitmap(m_bitmap) != SUCCESS)
if (!presenter->m_bitmap || presenter->m_bitmap->ImportBitmap(m_bitmap) != SUCCESS) {
goto done;
}
}
if (m_unk0x58)
if (m_unk0x58) {
presenter->m_unk0x58 = MxDisplaySurface::FUN_100bbfb0(m_unk0x58);
}
if (m_alpha)
if (m_alpha) {
presenter->m_alpha = new MxVideoPresenter::AlphaMask(*m_alpha);
}
result = SUCCESS;
}

View File

@@ -42,32 +42,39 @@ void MxVideoManager::Destroy(MxBool p_fromDestructor)
m_thread->Terminate();
delete m_thread;
}
else
else {
TickleManager()->UnregisterClient(this);
}
m_criticalSection.Enter();
if (m_displaySurface)
if (m_displaySurface) {
delete m_displaySurface;
}
if (m_region)
if (m_region) {
delete m_region;
}
if (m_videoParam.GetPalette())
if (m_videoParam.GetPalette()) {
delete m_videoParam.GetPalette();
}
if (m_unk0x60) {
if (m_pDirectDraw)
if (m_pDirectDraw) {
m_pDirectDraw->Release();
if (m_pDirect3D)
}
if (m_pDirect3D) {
m_pDirect3D->Release();
}
}
Init();
m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxMediaManager::Destroy();
}
}
// FUNCTION: LEGO1 0x100be3e0
@@ -85,8 +92,9 @@ void MxVideoManager::UpdateRegion()
// FUNCTION: LEGO1 0x100be440
void MxVideoManager::SortPresenterList()
{
if (this->m_presenters->GetCount() <= 1)
if (this->m_presenters->GetCount() <= 1) {
return;
}
MxPresenterListCursor a(this->m_presenters);
MxPresenterListCursor b(this->m_presenters);
@@ -132,8 +140,9 @@ MxResult MxVideoManager::VTable0x28(
m_unk0x60 = FALSE;
if (MxMediaManager::InitPresenters() != SUCCESS)
if (MxMediaManager::InitPresenters() != SUCCESS) {
goto done;
}
m_criticalSection.Enter();
locked = TRUE;
@@ -141,8 +150,9 @@ MxResult MxVideoManager::VTable0x28(
m_videoParam = p_videoParam;
m_region = new MxRegion();
if (!m_region)
if (!m_region) {
goto done;
}
m_pDirectDraw = p_pDirectDraw;
m_pDirect3D = p_pDirect3D;
@@ -152,15 +162,17 @@ MxResult MxVideoManager::VTable0x28(
palette = new MxPalette();
m_videoParam.SetPalette(palette);
if (!palette)
if (!palette) {
goto done;
}
}
else {
palette = p_videoParam.GetPalette()->Clone();
m_videoParam.SetPalette(palette);
if (!palette)
if (!palette) {
goto done;
}
}
m_displaySurface = new MxDisplaySurface();
@@ -170,21 +182,25 @@ MxResult MxVideoManager::VTable0x28(
if (p_createThread) {
m_thread = new MxTickleThread(this, p_frequencyMS);
if (!m_thread || m_thread->Start(0, 0) != SUCCESS)
if (!m_thread || m_thread->Start(0, 0) != SUCCESS) {
goto done;
}
}
else
else {
TickleManager()->RegisterClient(this, p_frequencyMS);
}
status = SUCCESS;
}
done:
if (status != SUCCESS)
if (status != SUCCESS) {
Destroy();
}
if (locked)
if (locked) {
m_criticalSection.Leave();
}
return status;
}
@@ -197,8 +213,9 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
m_unk0x60 = TRUE;
if (MxMediaManager::InitPresenters() != SUCCESS)
if (MxMediaManager::InitPresenters() != SUCCESS) {
goto done;
}
m_criticalSection.Enter();
locked = TRUE;
@@ -206,29 +223,34 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
m_videoParam = p_videoParam;
m_region = new MxRegion();
if (!m_region)
if (!m_region) {
goto done;
}
if (DirectDrawCreate(NULL, &m_pDirectDraw, NULL) != DD_OK)
if (DirectDrawCreate(NULL, &m_pDirectDraw, NULL) != DD_OK) {
goto done;
}
if (m_pDirectDraw->SetCooperativeLevel(MxOmni::GetInstance()->GetWindowHandle(), DDSCL_NORMAL) != DD_OK)
if (m_pDirectDraw->SetCooperativeLevel(MxOmni::GetInstance()->GetWindowHandle(), DDSCL_NORMAL) != DD_OK) {
goto done;
}
MxPalette* palette;
if (p_videoParam.GetPalette() == NULL) {
palette = new MxPalette();
m_videoParam.SetPalette(palette);
if (!palette)
if (!palette) {
goto done;
}
}
else {
palette = p_videoParam.GetPalette()->Clone();
m_videoParam.SetPalette(palette);
if (!palette)
if (!palette) {
goto done;
}
}
m_displaySurface = new MxDisplaySurface();
@@ -238,21 +260,25 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
if (p_createThread) {
m_thread = new MxTickleThread(this, p_frequencyMS);
if (!m_thread || m_thread->Start(0, 0) != SUCCESS)
if (!m_thread || m_thread->Start(0, 0) != SUCCESS) {
goto done;
}
}
else
else {
TickleManager()->RegisterClient(this, p_frequencyMS);
}
status = SUCCESS;
}
done:
if (status != SUCCESS)
if (status != SUCCESS) {
Destroy();
}
if (locked)
if (locked) {
m_criticalSection.Leave();
}
return status;
}
@@ -268,8 +294,9 @@ void MxVideoManager::InvalidateRect(MxRect32& p_rect)
{
m_criticalSection.Enter();
if (m_region)
if (m_region) {
m_region->VTable0x18(p_rect);
}
m_criticalSection.Leave();
}
@@ -284,13 +311,15 @@ MxResult MxVideoManager::Tickle()
MxPresenter* presenter;
MxPresenterListCursor cursor(this->m_presenters);
while (cursor.Next(presenter))
while (cursor.Next(presenter)) {
presenter->Tickle();
}
cursor.Reset();
while (cursor.Next(presenter))
while (cursor.Next(presenter)) {
presenter->PutData();
}
UpdateRegion();
m_region->Reset();

View File

@@ -46,15 +46,17 @@ MxVideoParam::MxVideoParam(MxVideoParam& p_videoParam)
// FUNCTION: LEGO1 0x100bed50
MxVideoParam::~MxVideoParam()
{
if (this->m_deviceId != NULL)
if (this->m_deviceId != NULL) {
delete[] this->m_deviceId;
}
}
// FUNCTION: LEGO1 0x100bed70
void MxVideoParam::SetDeviceName(char* p_deviceId)
{
if (this->m_deviceId != NULL)
if (this->m_deviceId != NULL) {
delete[] this->m_deviceId;
}
if (p_deviceId != NULL) {
this->m_deviceId = new char[strlen(p_deviceId) + 1];

View File

@@ -33,10 +33,12 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
switch (p_bitmap.GetBmiHeader()->biCompression) {
case BI_RGB: {
if (p_bitmap.GetBmiHeight() < 0)
if (p_bitmap.GetBmiHeight() < 0) {
rowsBeforeTop = 0;
else
}
else {
rowsBeforeTop = p_bitmap.GetBmiHeightAbs() - 1;
}
bitmapSrcPtr = p_bitmap.GetBitmapData() + (p_bitmap.GetBmiStride() * rowsBeforeTop);
break;
}
@@ -44,10 +46,12 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
bitmapSrcPtr = p_bitmap.GetBitmapData();
break;
default: {
if (p_bitmap.GetBmiHeight() < 0)
if (p_bitmap.GetBmiHeight() < 0) {
rowsBeforeTop = 0;
else
}
else {
rowsBeforeTop = p_bitmap.GetBmiHeightAbs() - 1;
}
bitmapSrcPtr = p_bitmap.GetBitmapData() + (p_bitmap.GetBmiStride() * rowsBeforeTop);
}
}
@@ -57,8 +61,9 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
// If this is a bottom-up DIB, we will walk it in reverse.
// TODO: Same rounding trick as in MxBitmap
MxS32 rowSeek = ((m_width + 3) & -4);
if (p_bitmap.GetBmiHeader()->biCompression != BI_RGB_TOPDOWN && p_bitmap.GetBmiHeight() > 0)
if (p_bitmap.GetBmiHeader()->biCompression != BI_RGB_TOPDOWN && p_bitmap.GetBmiHeight() > 0) {
rowSeek = -rowSeek;
}
// The actual offset into the m_bitmask array. The two for-loops
// are just for counting the pixels.
@@ -95,15 +100,17 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxVideoPresenter::AlphaMask& p_alph
// FUNCTION: LEGO1 0x100b26d0
MxVideoPresenter::AlphaMask::~AlphaMask()
{
if (m_bitmask)
if (m_bitmask) {
delete[] m_bitmask;
}
}
// FUNCTION: LEGO1 0x100b26f0
MxS32 MxVideoPresenter::AlphaMask::IsHit(MxU32 p_x, MxU32 p_y)
{
if (p_x >= m_width || p_y >= m_height)
if (p_x >= m_width || p_y >= m_height) {
return 0;
}
MxS32 pos = p_y * m_width + p_x;
return m_bitmask[pos / 8] & (1 << abs(abs(pos) & 7)) ? 1 : 0;
@@ -132,8 +139,9 @@ void MxVideoPresenter::Init()
// FUNCTION: LEGO1 0x100b27b0
void MxVideoPresenter::Destroy(MxBool p_fromDestructor)
{
if (MVideoManager() != NULL)
if (MVideoManager() != NULL) {
MVideoManager()->UnregisterPresenter(*this);
}
if (m_unk0x58) {
m_unk0x58->Release();
@@ -159,8 +167,9 @@ void MxVideoPresenter::Destroy(MxBool p_fromDestructor)
Init();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxMediaPresenter::Destroy(FALSE);
}
}
// FUNCTION: LEGO1 0x100b28b0
@@ -183,11 +192,13 @@ MxBool MxVideoPresenter::IsHit(MxS32 p_x, MxS32 p_y)
{
MxDSAction* action = GetAction();
if ((action == NULL) || (((action->GetFlags() & MxDSAction::c_bit11) == 0) && !IsEnabled()) ||
(!m_bitmap && !m_alpha))
(!m_bitmap && !m_alpha)) {
return FALSE;
}
if (!m_bitmap)
if (!m_bitmap) {
return m_alpha->IsHit(p_x - m_location.GetX(), p_y - m_location.GetY());
}
MxLong heightAbs = m_bitmap->GetBmiHeightAbs();
@@ -197,8 +208,9 @@ MxBool MxVideoPresenter::IsHit(MxS32 p_x, MxS32 p_y)
MxLong maxY = minY + heightAbs;
MxLong maxX = minX + m_bitmap->GetBmiWidth();
if (p_x < minX || p_x >= maxX || p_y < minY || p_y >= maxY)
if (p_x < minX || p_x >= maxX || p_y < minY || p_y >= maxY) {
return FALSE;
}
MxU8* pixel;
@@ -230,11 +242,13 @@ MxBool MxVideoPresenter::IsHit(MxS32 p_x, MxS32 p_y)
pixel = m_bitmap->GetBmiStride() * height + m_bitmap->GetBitmapData();
}
if (GetBit4())
if (GetBit4()) {
return (MxBool) *pixel;
}
if ((GetAction()->GetFlags() & MxDSAction::c_bit4) && *pixel == 0)
if ((GetAction()->GetFlags() & MxDSAction::c_bit4) && *pixel == 0) {
return FALSE;
}
return TRUE;
}
@@ -242,32 +256,40 @@ MxBool MxVideoPresenter::IsHit(MxS32 p_x, MxS32 p_y)
inline MxS32 MxVideoPresenter::PrepareRects(MxRect32& p_rectDest, MxRect32& p_rectSrc)
{
if (p_rectDest.GetTop() > 480 || p_rectDest.GetLeft() > 640 || p_rectSrc.GetTop() > 480 ||
p_rectSrc.GetLeft() > 640)
p_rectSrc.GetLeft() > 640) {
return -1;
}
if (p_rectDest.GetBottom() > 480)
if (p_rectDest.GetBottom() > 480) {
p_rectDest.SetBottom(480);
}
if (p_rectDest.GetRight() > 640)
if (p_rectDest.GetRight() > 640) {
p_rectDest.SetRight(640);
}
if (p_rectSrc.GetBottom() > 480)
if (p_rectSrc.GetBottom() > 480) {
p_rectSrc.SetBottom(480);
}
if (p_rectSrc.GetRight() > 640)
if (p_rectSrc.GetRight() > 640) {
p_rectSrc.SetRight(640);
}
MxS32 height = p_rectDest.GetHeight();
if (height <= 1)
if (height <= 1) {
return -1;
}
MxS32 width = p_rectDest.GetWidth();
if (width <= 1)
if (width <= 1) {
return -1;
}
if (p_rectSrc.GetRight() - width - p_rectSrc.GetLeft() == -1 &&
p_rectSrc.GetBottom() - height - p_rectSrc.GetTop() == -1)
p_rectSrc.GetBottom() - height - p_rectSrc.GetTop() == -1) {
return 1;
}
p_rectSrc.SetRight(p_rectSrc.GetLeft() + width - 1);
p_rectSrc.SetBottom(p_rectSrc.GetTop() + height - 1);
@@ -325,7 +347,7 @@ void MxVideoPresenter::PutFrame()
MxRegionCursor cursor(region);
MxRect32* regionRect;
while (regionRect = cursor.VTable0x24(rect)) {
while ((regionRect = cursor.VTable0x24(rect))) {
if (regionRect->GetWidth() >= 1 && regionRect->GetHeight() >= 1) {
if (m_unk0x58) {
rectSrc.SetLeft(regionRect->GetLeft() - m_location.GetX());
@@ -341,8 +363,9 @@ void MxVideoPresenter::PutFrame()
if (m_action->GetFlags() & MxDSAction::c_bit4) {
if (m_unk0x58) {
if (PrepareRects(rectDest, rectSrc) >= 0)
if (PrepareRects(rectDest, rectSrc) >= 0) {
ddSurface->Blt((LPRECT) &rectDest, m_unk0x58, (LPRECT) &rectSrc, DDBLT_KEYSRC, NULL);
}
}
else {
displaySurface->VTable0x30(
@@ -358,8 +381,9 @@ void MxVideoPresenter::PutFrame()
}
}
else if (m_unk0x58) {
if (PrepareRects(rectDest, rectSrc) >= 0)
if (PrepareRects(rectDest, rectSrc) >= 0) {
ddSurface->Blt((LPRECT) &rectDest, m_unk0x58, (LPRECT) &rectSrc, 0, NULL);
}
}
else {
displaySurface->VTable0x28(
@@ -405,8 +429,9 @@ void MxVideoPresenter::StartingTickle()
void MxVideoPresenter::StreamingTickle()
{
if (m_action->GetFlags() & MxDSAction::c_bit10) {
if (!m_currentChunk)
if (!m_currentChunk) {
MxMediaPresenter::StreamingTickle();
}
if (m_currentChunk) {
LoadFrame(m_currentChunk);
@@ -418,24 +443,28 @@ void MxVideoPresenter::StreamingTickle()
if (!m_currentChunk) {
MxMediaPresenter::StreamingTickle();
if (!m_currentChunk)
if (!m_currentChunk) {
break;
}
}
if (m_action->GetElapsedTime() < m_currentChunk->GetTime())
if (m_action->GetElapsedTime() < m_currentChunk->GetTime()) {
break;
}
LoadFrame(m_currentChunk);
m_subscriber->DestroyChunk(m_currentChunk);
m_currentChunk = NULL;
SetBit0(TRUE);
if (m_currentTickleState != e_streaming)
if (m_currentTickleState != e_streaming) {
break;
}
}
if (GetBit0())
if (GetBit0()) {
m_unk0x5c = 5;
}
}
}
@@ -444,8 +473,9 @@ void MxVideoPresenter::RepeatingTickle()
{
if (IsEnabled()) {
if (m_action->GetFlags() & MxDSAction::c_bit10) {
if (!m_currentChunk)
if (!m_currentChunk) {
MxMediaPresenter::RepeatingTickle();
}
if (m_currentChunk) {
LoadFrame(m_currentChunk);
@@ -457,23 +487,27 @@ void MxVideoPresenter::RepeatingTickle()
if (!m_currentChunk) {
MxMediaPresenter::RepeatingTickle();
if (!m_currentChunk)
if (!m_currentChunk) {
break;
}
}
if (m_action->GetElapsedTime() % m_action->GetLoopCount() < m_currentChunk->GetTime())
if (m_action->GetElapsedTime() % m_action->GetLoopCount() < m_currentChunk->GetTime()) {
break;
}
LoadFrame(m_currentChunk);
m_currentChunk = NULL;
SetBit0(TRUE);
if (m_currentTickleState != e_repeating)
if (m_currentTickleState != e_repeating) {
break;
}
}
if (GetBit0())
if (GetBit0()) {
m_unk0x5c = 5;
}
}
}
}
@@ -485,14 +519,17 @@ void MxVideoPresenter::Unk5Tickle()
if (sustainTime != -1) {
if (sustainTime) {
if (m_unk0x60 == -1)
if (m_unk0x60 == -1) {
m_unk0x60 = m_action->GetElapsedTime();
}
if (m_action->GetElapsedTime() >= m_unk0x60 + ((MxDSMediaAction*) m_action)->GetSustainTime())
if (m_action->GetElapsedTime() >= m_unk0x60 + ((MxDSMediaAction*) m_action)->GetSustainTime()) {
ProgressTickleState(e_done);
}
}
else
else {
ProgressTickleState(e_done);
}
}
}
@@ -534,8 +571,9 @@ MxResult MxVideoPresenter::PutData()
{
MxAutoLocker lock(&m_criticalSection);
if (IsEnabled() && m_currentTickleState >= e_streaming && m_currentTickleState <= e_unk5)
if (IsEnabled() && m_currentTickleState >= e_streaming && m_currentTickleState <= e_unk5) {
PutFrame();
}
return SUCCESS;
}