mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
Fix remaning UBSAN issues (#115)
This commit is contained in:
parent
4e2df63d9c
commit
70536c50bd
@ -9,6 +9,7 @@
|
|||||||
#include "mxtimer.h"
|
#include "mxtimer.h"
|
||||||
#include "mxutilities.h"
|
#include "mxutilities.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_log.h>
|
||||||
#include <SDL3/SDL_stdinc.h>
|
#include <SDL3/SDL_stdinc.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
@ -78,7 +79,11 @@ void MxControlPresenter::EndAction()
|
|||||||
MxBool MxControlPresenter::FUN_10044270(MxS32 p_x, MxS32 p_y, MxPresenter* p_presenter)
|
MxBool MxControlPresenter::FUN_10044270(MxS32 p_x, MxS32 p_y, MxPresenter* p_presenter)
|
||||||
{
|
{
|
||||||
assert(p_presenter);
|
assert(p_presenter);
|
||||||
MxStillPresenter* presenter = (MxStillPresenter*) p_presenter;
|
MxStillPresenter* presenter = dynamic_cast<MxStillPresenter*>(p_presenter);
|
||||||
|
if (!presenter) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid presenter");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_unk0x4c == 3) {
|
if (m_unk0x4c == 3) {
|
||||||
MxStillPresenter* map = (MxStillPresenter*) m_list.front();
|
MxStillPresenter* map = (MxStillPresenter*) m_list.front();
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
#include "legopathactor.h"
|
#include "legopathactor.h"
|
||||||
#include "legopathstruct.h"
|
#include "legopathstruct.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_log.h>
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(LegoPathBoundary, 0x74)
|
DECOMP_SIZE_ASSERT(LegoPathBoundary, 0x74)
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10056a70
|
// FUNCTION: LEGO1 0x10056a70
|
||||||
@ -357,8 +359,12 @@ MxU32 LegoPathBoundary::FUN_10057fe0(LegoAnimPresenter* p_presenter)
|
|||||||
// TODO: This only seems to match if the type is not the same as the type of the
|
// TODO: This only seems to match if the type is not the same as the type of the
|
||||||
// key value of the set. Figure out which type the set (or parameter) actually uses.
|
// key value of the set. Figure out which type the set (or parameter) actually uses.
|
||||||
// Also see call to .find in LegoPathController::FUN_10046050
|
// Also see call to .find in LegoPathController::FUN_10046050
|
||||||
m_presenters.insert(static_cast<LegoLocomotionAnimPresenter*>(p_presenter));
|
if (auto* locomotionPresenter = dynamic_cast<LegoLocomotionAnimPresenter*>(p_presenter)) {
|
||||||
return 1;
|
m_presenters.insert(locomotionPresenter);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid locomotion");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100586e0
|
// FUNCTION: LEGO1 0x100586e0
|
||||||
@ -369,8 +375,14 @@ MxU32 LegoPathBoundary::FUN_100586e0(LegoAnimPresenter* p_presenter)
|
|||||||
// TODO: This only seems to match if the type is not the same as the type of the
|
// TODO: This only seems to match if the type is not the same as the type of the
|
||||||
// key value of the set. Figure out which type the set (or parameter) actually uses.
|
// key value of the set. Figure out which type the set (or parameter) actually uses.
|
||||||
// Also see call to .find in LegoPathController::FUN_10046050
|
// Also see call to .find in LegoPathController::FUN_10046050
|
||||||
if (m_presenters.find(static_cast<LegoLocomotionAnimPresenter*>(p_presenter)) != m_presenters.end()) {
|
auto* locomotionPresenter = dynamic_cast<LegoLocomotionAnimPresenter*>(p_presenter);
|
||||||
m_presenters.erase(static_cast<LegoLocomotionAnimPresenter*>(p_presenter));
|
if (!locomotionPresenter) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid locomotion");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
auto it = m_presenters.find(locomotionPresenter);
|
||||||
|
if (it != m_presenters.end()) {
|
||||||
|
m_presenters.erase(it);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,7 +93,7 @@ void LegoPhonemePresenter::LoadFrame(MxStreamChunk* p_chunk)
|
|||||||
{
|
{
|
||||||
MxU8* data = p_chunk->GetData();
|
MxU8* data = p_chunk->GetData();
|
||||||
|
|
||||||
m_rectCount = *(MxS32*) data;
|
m_rectCount = UnalignedRead<MxS32>(data);
|
||||||
data += sizeof(MxS32);
|
data += sizeof(MxS32);
|
||||||
|
|
||||||
MxRect32* rects = (MxRect32*) data;
|
MxRect32* rects = (MxRect32*) data;
|
||||||
|
|||||||
@ -159,9 +159,10 @@ void WritePixelPairs(
|
|||||||
short is_odd = p_count & 1;
|
short is_odd = p_count & 1;
|
||||||
p_count >>= 1;
|
p_count >>= 1;
|
||||||
|
|
||||||
WORD* dst = (WORD*) (((p_bitmapHeader->biWidth + 3) & -4) * p_row + p_column + p_pixelData);
|
BYTE* dst = ((p_bitmapHeader->biWidth + 3) & -4) * p_row + p_column + p_pixelData;
|
||||||
while (--p_count >= 0) {
|
while (--p_count >= 0) {
|
||||||
*dst++ = p_pixel;
|
memcpy(dst, &p_pixel, sizeof(WORD));
|
||||||
|
dst += sizeof(WORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_odd) {
|
if (is_odd) {
|
||||||
|
|||||||
@ -49,10 +49,10 @@ void MxFlcPresenter::LoadFrame(MxStreamChunk* p_chunk)
|
|||||||
{
|
{
|
||||||
MxU8* data = p_chunk->GetData();
|
MxU8* data = p_chunk->GetData();
|
||||||
|
|
||||||
MxS32 rectCount = *(MxS32*) data;
|
MxS32 rectCount = UnalignedRead<MxS32>(data);
|
||||||
data += sizeof(MxS32);
|
data += sizeof(MxS32);
|
||||||
|
|
||||||
MxRect32* rects = (MxRect32*) data;
|
MxU8* rects = data;
|
||||||
data += rectCount * sizeof(MxRect32);
|
data += rectCount * sizeof(MxRect32);
|
||||||
|
|
||||||
MxBool decodedColorMap;
|
MxBool decodedColorMap;
|
||||||
@ -69,7 +69,8 @@ void MxFlcPresenter::LoadFrame(MxStreamChunk* p_chunk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (MxS32 i = 0; i < rectCount; i++) {
|
for (MxS32 i = 0; i < rectCount; i++) {
|
||||||
MxRect32 rect(rects[i]);
|
MxRect32 rect = UnalignedRead<MxRect32>(rects);
|
||||||
|
rects += sizeof(MxRect32);
|
||||||
rect += m_location;
|
rect += m_location;
|
||||||
MVideoManager()->InvalidateRect(rect);
|
MVideoManager()->InvalidateRect(rect);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "impl.h"
|
#include "impl.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_log.h>
|
||||||
|
|
||||||
using namespace TglImpl;
|
using namespace TglImpl;
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100a31d0
|
// FUNCTION: LEGO1 0x100a31d0
|
||||||
@ -89,7 +91,11 @@ Result GroupImpl::Add(const Group* pGroup)
|
|||||||
// FUNCTION: LEGO1 0x100a3430
|
// FUNCTION: LEGO1 0x100a3430
|
||||||
Result GroupImpl::Add(const MeshBuilder* pMeshBuilder)
|
Result GroupImpl::Add(const MeshBuilder* pMeshBuilder)
|
||||||
{
|
{
|
||||||
const MeshBuilderImpl* pMeshBuilderImpl = static_cast<const MeshBuilderImpl*>(pMeshBuilder);
|
const MeshBuilderImpl* pMeshBuilderImpl = dynamic_cast<const MeshBuilderImpl*>(pMeshBuilder);
|
||||||
|
if (!pMeshBuilderImpl) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid mesh builder");
|
||||||
|
return Result::Error;
|
||||||
|
}
|
||||||
return ResultVal(m_data->AddVisual(pMeshBuilderImpl->ImplementationData()));
|
return ResultVal(m_data->AddVisual(pMeshBuilderImpl->ImplementationData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user