summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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.cpp8
-rw-r--r--src/text/Text.h4
6 files changed, 53 insertions, 13 deletions
diff --git a/src/core/config.h b/src/core/config.h
index a2b2b6fc..ce7ee1e3 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -226,11 +226,15 @@ enum Config {
# define TIMEBARS // print debug timers
#endif
-#define FIX_BUGS // fixes bugs that we've came across during reversing
+#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
+#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 MISSION_SWITCHER // from debug menu
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 0bd87dbc..24017e19 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -783,9 +783,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){
@@ -881,7 +885,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;
@@ -911,7 +921,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){
@@ -939,7 +954,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){
@@ -967,7 +987,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);
@@ -1004,7 +1029,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;
@@ -1022,7 +1052,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 dd356b96..d004656c 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -291,7 +291,8 @@ SkinGetBonePositionsToTable(RpClump *clump, RwV3d *boneTable)
parent = stack[sp--];
else
parent = i;
- assert(parent >= 0 && parent < numBones);
+
+ //assert(parent >= 0 && parent < numBones);
}
}
@@ -299,7 +300,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;
@@ -313,7 +314,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;
@@ -401,7 +402,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 0c63ced7..fe37d0f1 100644
--- a/src/text/Text.cpp
+++ b/src/text/Text.cpp
@@ -97,7 +97,7 @@ CText::Unload(void)
wchar*
CText::Get(const char *key)
{
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
return keyArray.Search(key, data.chars);
#else
return keyArray.Search(key);
@@ -201,7 +201,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);
@@ -229,7 +229,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)
#else
CKeyArray::Search(const char *key)
@@ -239,7 +239,7 @@ CKeyArray::Search(const char *key)
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)
return (wchar*)((uint8*)data + found->valueOffset);
diff --git a/src/text/Text.h b/src/text/Text.h
index ed978a8b..ab6d1809 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);
#else
wchar *Search(const char *key);