From c54d3ba2ab218b9545e784abaf39b4054d3de4bc Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 16 May 2020 14:34:51 +0200 Subject: fixes for 64 bit build --- src/rw/RwHelper.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/rw/RwHelper.cpp') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 5026e2c8..191fc7ab 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -59,6 +59,16 @@ void FlushObrsPrintfs() void * RwMallocAlign(RwUInt32 size, RwUInt32 align) { +#ifdef FIX_BUGS + uintptr ptralign = align-1; + void *mem = (void *)malloc(size + sizeof(uintptr) + ptralign); + + ASSERT(mem != nil); + + void *addr = (void *)((((uintptr)mem) + sizeof(uintptr) + ptralign) & ~ptralign); + + ASSERT(addr != nil); +#else void *mem = (void *)malloc(size + align); ASSERT(mem != nil); @@ -66,6 +76,7 @@ RwMallocAlign(RwUInt32 size, RwUInt32 align) void *addr = (void *)((((uintptr)mem) + align) & ~(align - 1)); ASSERT(addr != nil); +#endif *(((void **)addr) - 1) = mem; -- cgit v1.2.3 From 8bbb6a2a4a104469f1c3a285f68088445332d671 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 1 Jun 2020 20:28:04 +0200 Subject: hanim fix --- src/rw/RwHelper.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/rw/RwHelper.cpp') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 191fc7ab..cd2a1bf6 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -319,14 +319,20 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier) RpHAnimAnimation *anim = RpHAnimAnimationCreate(rpHANIMSTDKEYFRAMETYPEID, numNodes, 0, 0.0f); if(anim == nil) return nil; - RpHAnimStdKeyFrame *frame = (RpHAnimStdKeyFrame*)HANIMFRAMES(anim); + RpHAnimStdKeyFrame *frame; for(i = 0; i < numNodes; i++){ + frame = (RpHAnimStdKeyFrame*)HANIMFRAME(anim, i); // games uses struct size here, not safe frame->q.real = 1.0f; frame->q.imag.x = frame->q.imag.y = frame->q.imag.z = 0.0f; frame->t.x = frame->t.y = frame->t.z = 0.0f; +#ifdef FIX_BUGS + // times are subtracted and divided giving NaNs + // so they can't both be 0 + frame->time = i/hier->numNodes; +#else frame->time = 0.0f; +#endif frame->prevFrame = nil; - frame++; } return anim; } -- cgit v1.2.3