summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-01-13 01:08:50 +0100
committererorcun <erorcunerorcun@hotmail.com.tr>2021-01-13 01:08:50 +0100
commit542a5393acae66a9add32c195939b058bf154b15 (patch)
tree97014f1f52bd206b4481fff07cd3ded01753cf98
parentMerge pull request #956 from withmorten/miami (diff)
downloadre3-542a5393acae66a9add32c195939b058bf154b15.tar
re3-542a5393acae66a9add32c195939b058bf154b15.tar.gz
re3-542a5393acae66a9add32c195939b058bf154b15.tar.bz2
re3-542a5393acae66a9add32c195939b058bf154b15.tar.lz
re3-542a5393acae66a9add32c195939b058bf154b15.tar.xz
re3-542a5393acae66a9add32c195939b058bf154b15.tar.zst
re3-542a5393acae66a9add32c195939b058bf154b15.zip
-rw-r--r--src/core/config.h6
-rw-r--r--src/entities/Physical.cpp37
-rw-r--r--src/rw/MemoryMgr.cpp2
-rw-r--r--src/rw/RwHelper.cpp9
-rw-r--r--src/text/Text.cpp10
-rw-r--r--src/text/Text.h4
6 files changed, 54 insertions, 14 deletions
diff --git a/src/core/config.h b/src/core/config.h
index 8e528a67..2ce692b5 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -238,12 +238,16 @@ enum Config {
# define TIMEBARS // print debug timers
#endif
-#define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more
+#define FIX_BUGS // fixes bugs that we've came across during reversing. You can undefine this only on release builds.
//#define MORE_LANGUAGES // Add more translations to the game
#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
#define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS
#define FIX_HIGH_FPS_BUGS_ON_FRONTEND
+#if defined(__LP64__) || defined(_WIN64)
+#define FIX_BUGS_64 // Must have fixes to be able to run 64 bit build
+#endif
+
// Just debug menu entries
#ifdef DEBUGMENU
#define RELOADABLES // some debug menu options to reload TXD files
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 706b469c..07d1d0b4 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -883,9 +883,13 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(B->GetStatus() == STATUS_PLAYER)
pointposB *= 0.8f;
if(CWorld::bNoMoreCollisionTorque){
- // BUG: the game actually uses A here, but this can't be right
+#ifdef FIX_BUGS
B->ApplyFrictionMoveForce(fB*-0.3f);
B->ApplyFrictionTurnForce(fB*-0.3f, pointposB);
+#else
+ A->ApplyFrictionMoveForce(fB*-0.3f);
+ A->ApplyFrictionTurnForce(fB*-0.3f, pointposB);
+#endif
}
}
if(!A->bInfiniteMass){
@@ -1054,7 +1058,13 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
fOtherSpeedA = vOtherSpeedA.Magnitude();
fOtherSpeedB = vOtherSpeedB.Magnitude();
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeedA;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
+#endif
+
speedSum = (B->m_fMass*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(B->m_fMass + A->m_fMass);
if(fOtherSpeedA > speedSum){
impulseA = (speedSum - fOtherSpeedA) * A->m_fMass;
@@ -1084,7 +1094,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
fOtherSpeedA = vOtherSpeedA.Magnitude();
fOtherSpeedB = vOtherSpeedB.Magnitude();
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeedA;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
+#endif
float massB = B->GetMass(pointposB, frictionDir);
speedSum = (massB*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(massB + A->m_fMass);
if(fOtherSpeedA > speedSum){
@@ -1112,7 +1127,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
fOtherSpeedA = vOtherSpeedA.Magnitude();
fOtherSpeedB = vOtherSpeedB.Magnitude();
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeedA;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
+#endif
float massA = A->GetMass(pointposA, frictionDir);
speedSum = (B->m_fMass*fOtherSpeedB + massA*fOtherSpeedA)/(B->m_fMass + massA);
if(fOtherSpeedA > speedSum){
@@ -1140,7 +1160,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
fOtherSpeedA = vOtherSpeedA.Magnitude();
fOtherSpeedB = vOtherSpeedB.Magnitude();
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeedA;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
+#endif
float massA = A->GetMass(pointposA, frictionDir);
float massB = B->GetMass(pointposB, frictionDir);
speedSum = (massB*fOtherSpeedB + massA*fOtherSpeedA)/(massB + massA);
@@ -1178,7 +1203,12 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
fOtherSpeed = vOtherSpeed.Magnitude();
if(fOtherSpeed > 0.0f){
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeed;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
+#endif
// not really impulse but speed
// maybe use ApplyFrictionMoveForce instead?
fImpulse = -fOtherSpeed;
@@ -1196,7 +1226,12 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
fOtherSpeed = vOtherSpeed.Magnitude();
if(fOtherSpeed > 0.0f){
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeed;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
+#endif
fImpulse = -fOtherSpeed * m_fMass;
impulseLimit = adhesiveLimit*CTimer::GetTimeStep() * 1.5;
if(fImpulse < -impulseLimit) fImpulse = -impulseLimit;
diff --git a/src/rw/MemoryMgr.cpp b/src/rw/MemoryMgr.cpp
index e2f6f144..2379692c 100644
--- a/src/rw/MemoryMgr.cpp
+++ b/src/rw/MemoryMgr.cpp
@@ -93,7 +93,7 @@ MemoryMgrFree(void *ptr)
void *
RwMallocAlign(RwUInt32 size, RwUInt32 align)
{
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
uintptr ptralign = align-1;
void *mem = (void *)MemoryMgrMalloc(size + sizeof(uintptr) + ptralign);
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp
index cab3b68c..d3fbd1d0 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -255,7 +255,8 @@ SkinGetBonePositionsToTable(RpClump *clump, RwV3d *boneTable)
parent = stack[sp--];
else
parent = i;
- assert(parent >= 0 && parent < numBones);
+
+ //assert(parent >= 0 && parent < numBones);
}
}
@@ -263,7 +264,7 @@ RpHAnimAnimation*
HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
{
int i;
-#ifdef FIX_BUGS
+#if defined FIX_BUGS || defined LIBRW
int numNodes = hier->numNodes*2; // you're supposed to have at least two KFs per node
#else
int numNodes = hier->numNodes;
@@ -277,7 +278,7 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
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
+#if defined FIX_BUGS || defined LIBRW
// times are subtracted and divided giving NaNs
// so they can't both be 0
frame->time = i/hier->numNodes;
@@ -483,7 +484,7 @@ CameraSize(RwCamera * camera, RwRect * rect,
RwRaster *zRaster;
// BUG: game just changes camera raster's sizes, but this is a hack
-#ifdef FIX_BUGS
+#if defined FIX_BUGS || defined LIBRW
/*
* Destroy rasters...
*/
diff --git a/src/text/Text.cpp b/src/text/Text.cpp
index 5f7a07cc..7afd64d2 100644
--- a/src/text/Text.cpp
+++ b/src/text/Text.cpp
@@ -111,14 +111,14 @@ wchar*
CText::Get(const char *key)
{
uint8 result = false;
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
wchar *outstr = keyArray.Search(key, data.chars, &result);
#else
wchar *outstr = keyArray.Search(key, &result);
#endif
if (!result && bHasMissionTextOffsets && bIsMissionTextLoaded)
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
outstr = mission_keyArray.Search(key, mission_data.chars, &result);
#else
outstr = mission_keyArray.Search(key, &result);
@@ -340,7 +340,7 @@ CKeyArray::Unload(void)
void
CKeyArray::Update(wchar *chars)
{
-#ifndef FIX_BUGS
+#if !defined(FIX_BUGS) && !defined(FIX_BUGS_64)
int i;
for(i = 0; i < numEntries; i++)
entries[i].value = (wchar*)((uint8*)chars + (uintptr)entries[i].value);
@@ -368,7 +368,7 @@ CKeyArray::BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 hi
}
wchar*
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
CKeyArray::Search(const char *key, wchar *data, uint8 *result)
#else
CKeyArray::Search(const char *key, uint8 *result)
@@ -378,7 +378,7 @@ CKeyArray::Search(const char *key, uint8 *result)
char errstr[25];
int i;
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
found = BinarySearch(key, entries, 0, numEntries-1);
if (found) {
*result = true;
diff --git a/src/text/Text.h b/src/text/Text.h
index 33dc313e..1174216c 100644
--- a/src/text/Text.h
+++ b/src/text/Text.h
@@ -7,7 +7,7 @@ void TextCopy(wchar *dst, const wchar *src);
struct CKeyEntry
{
-#ifdef FIX_BUGS
+#if defined(FIX_BUGS) || defined(FIX_BUGS_64)
uint32 valueOffset;
#else
wchar *value;
@@ -30,7 +30,7 @@ public:
void Unload(void);
void Update(wchar *chars);
CKeyEntry *BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high);
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
wchar *Search(const char *key, wchar *data, uint8 *result);
#else
wchar *Search(const char *key, uint8* result);