mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 00:50:00 +00:00
Fix build without FIX_BUGS, divide to 0 fixes
This commit is contained in:
parent
4097c20bdd
commit
57201187de
|
@ -226,11 +226,15 @@ enum Config {
|
||||||
# define TIMEBARS // print debug timers
|
# define TIMEBARS // print debug timers
|
||||||
#endif
|
#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 MORE_LANGUAGES // Add more translations to the game
|
||||||
#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
|
#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 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
|
// Just debug menu entries
|
||||||
#ifdef DEBUGMENU
|
#ifdef DEBUGMENU
|
||||||
#define MISSION_SWITCHER // from debug menu
|
#define MISSION_SWITCHER // from debug menu
|
||||||
|
|
|
@ -783,9 +783,13 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
|
||||||
if(B->GetStatus() == STATUS_PLAYER)
|
if(B->GetStatus() == STATUS_PLAYER)
|
||||||
pointposB *= 0.8f;
|
pointposB *= 0.8f;
|
||||||
if(CWorld::bNoMoreCollisionTorque){
|
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->ApplyFrictionMoveForce(fB*-0.3f);
|
||||||
B->ApplyFrictionTurnForce(fB*-0.3f, pointposB);
|
B->ApplyFrictionTurnForce(fB*-0.3f, pointposB);
|
||||||
|
#else
|
||||||
|
A->ApplyFrictionMoveForce(fB*-0.3f);
|
||||||
|
A->ApplyFrictionTurnForce(fB*-0.3f, pointposB);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!A->bInfiniteMass){
|
if(!A->bInfiniteMass){
|
||||||
|
@ -881,7 +885,13 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
|
||||||
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
||||||
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
||||||
|
|
||||||
|
#ifdef FIX_BUGS // division by 0
|
||||||
|
frictionDir = vOtherSpeedA;
|
||||||
|
frictionDir.Normalise();
|
||||||
|
#else
|
||||||
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
||||||
|
#endif
|
||||||
|
|
||||||
speedSum = (B->m_fMass*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(B->m_fMass + A->m_fMass);
|
speedSum = (B->m_fMass*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(B->m_fMass + A->m_fMass);
|
||||||
if(fOtherSpeedA > speedSum){
|
if(fOtherSpeedA > speedSum){
|
||||||
impulseA = (speedSum - fOtherSpeedA) * A->m_fMass;
|
impulseA = (speedSum - fOtherSpeedA) * A->m_fMass;
|
||||||
|
@ -911,7 +921,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
|
||||||
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
||||||
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
||||||
|
|
||||||
|
#ifdef FIX_BUGS // division by 0
|
||||||
|
frictionDir = vOtherSpeedA;
|
||||||
|
frictionDir.Normalise();
|
||||||
|
#else
|
||||||
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
||||||
|
#endif
|
||||||
float massB = B->GetMass(pointposB, frictionDir);
|
float massB = B->GetMass(pointposB, frictionDir);
|
||||||
speedSum = (massB*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(massB + A->m_fMass);
|
speedSum = (massB*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(massB + A->m_fMass);
|
||||||
if(fOtherSpeedA > speedSum){
|
if(fOtherSpeedA > speedSum){
|
||||||
|
@ -939,7 +954,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
|
||||||
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
||||||
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
||||||
|
|
||||||
|
#ifdef FIX_BUGS // division by 0
|
||||||
|
frictionDir = vOtherSpeedA;
|
||||||
|
frictionDir.Normalise();
|
||||||
|
#else
|
||||||
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
||||||
|
#endif
|
||||||
float massA = A->GetMass(pointposA, frictionDir);
|
float massA = A->GetMass(pointposA, frictionDir);
|
||||||
speedSum = (B->m_fMass*fOtherSpeedB + massA*fOtherSpeedA)/(B->m_fMass + massA);
|
speedSum = (B->m_fMass*fOtherSpeedB + massA*fOtherSpeedA)/(B->m_fMass + massA);
|
||||||
if(fOtherSpeedA > speedSum){
|
if(fOtherSpeedA > speedSum){
|
||||||
|
@ -967,7 +987,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
|
||||||
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
||||||
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
||||||
|
|
||||||
|
#ifdef FIX_BUGS // division by 0
|
||||||
|
frictionDir = vOtherSpeedA;
|
||||||
|
frictionDir.Normalise();
|
||||||
|
#else
|
||||||
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
||||||
|
#endif
|
||||||
float massA = A->GetMass(pointposA, frictionDir);
|
float massA = A->GetMass(pointposA, frictionDir);
|
||||||
float massB = B->GetMass(pointposB, frictionDir);
|
float massB = B->GetMass(pointposB, frictionDir);
|
||||||
speedSum = (massB*fOtherSpeedB + massA*fOtherSpeedA)/(massB + massA);
|
speedSum = (massB*fOtherSpeedB + massA*fOtherSpeedA)/(massB + massA);
|
||||||
|
@ -1004,7 +1029,12 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
|
||||||
|
|
||||||
fOtherSpeed = vOtherSpeed.Magnitude();
|
fOtherSpeed = vOtherSpeed.Magnitude();
|
||||||
if(fOtherSpeed > 0.0f){
|
if(fOtherSpeed > 0.0f){
|
||||||
|
#ifdef FIX_BUGS // division by 0
|
||||||
|
frictionDir = vOtherSpeed;
|
||||||
|
frictionDir.Normalise();
|
||||||
|
#else
|
||||||
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
|
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
|
||||||
|
#endif
|
||||||
// not really impulse but speed
|
// not really impulse but speed
|
||||||
// maybe use ApplyFrictionMoveForce instead?
|
// maybe use ApplyFrictionMoveForce instead?
|
||||||
fImpulse = -fOtherSpeed;
|
fImpulse = -fOtherSpeed;
|
||||||
|
@ -1022,7 +1052,12 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
|
||||||
|
|
||||||
fOtherSpeed = vOtherSpeed.Magnitude();
|
fOtherSpeed = vOtherSpeed.Magnitude();
|
||||||
if(fOtherSpeed > 0.0f){
|
if(fOtherSpeed > 0.0f){
|
||||||
|
#ifdef FIX_BUGS // division by 0
|
||||||
|
frictionDir = vOtherSpeed;
|
||||||
|
frictionDir.Normalise();
|
||||||
|
#else
|
||||||
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
|
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
|
||||||
|
#endif
|
||||||
fImpulse = -fOtherSpeed * m_fMass;
|
fImpulse = -fOtherSpeed * m_fMass;
|
||||||
impulseLimit = adhesiveLimit*CTimer::GetTimeStep() * 1.5;
|
impulseLimit = adhesiveLimit*CTimer::GetTimeStep() * 1.5;
|
||||||
if(fImpulse < -impulseLimit) fImpulse = -impulseLimit;
|
if(fImpulse < -impulseLimit) fImpulse = -impulseLimit;
|
||||||
|
|
|
@ -93,7 +93,7 @@ MemoryMgrFree(void *ptr)
|
||||||
void *
|
void *
|
||||||
RwMallocAlign(RwUInt32 size, RwUInt32 align)
|
RwMallocAlign(RwUInt32 size, RwUInt32 align)
|
||||||
{
|
{
|
||||||
#ifdef FIX_BUGS
|
#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
|
||||||
uintptr ptralign = align-1;
|
uintptr ptralign = align-1;
|
||||||
void *mem = (void *)MemoryMgrMalloc(size + sizeof(uintptr) + ptralign);
|
void *mem = (void *)MemoryMgrMalloc(size + sizeof(uintptr) + ptralign);
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,8 @@ SkinGetBonePositionsToTable(RpClump *clump, RwV3d *boneTable)
|
||||||
parent = stack[sp--];
|
parent = stack[sp--];
|
||||||
else
|
else
|
||||||
parent = i;
|
parent = i;
|
||||||
assert(parent >= 0 && parent < numBones);
|
|
||||||
|
//assert(parent >= 0 && parent < numBones);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +300,7 @@ RpHAnimAnimation*
|
||||||
HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
|
HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
|
||||||
{
|
{
|
||||||
int i;
|
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
|
int numNodes = hier->numNodes*2; // you're supposed to have at least two KFs per node
|
||||||
#else
|
#else
|
||||||
int numNodes = hier->numNodes;
|
int numNodes = hier->numNodes;
|
||||||
|
@ -313,7 +314,7 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
|
||||||
frame->q.real = 1.0f;
|
frame->q.real = 1.0f;
|
||||||
frame->q.imag.x = frame->q.imag.y = frame->q.imag.z = 0.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;
|
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
|
// times are subtracted and divided giving NaNs
|
||||||
// so they can't both be 0
|
// so they can't both be 0
|
||||||
frame->time = i/hier->numNodes;
|
frame->time = i/hier->numNodes;
|
||||||
|
@ -401,7 +402,7 @@ CameraSize(RwCamera * camera, RwRect * rect,
|
||||||
RwRaster *zRaster;
|
RwRaster *zRaster;
|
||||||
|
|
||||||
// BUG: game just changes camera raster's sizes, but this is a hack
|
// BUG: game just changes camera raster's sizes, but this is a hack
|
||||||
#ifdef FIX_BUGS
|
#if defined FIX_BUGS || defined LIBRW
|
||||||
/*
|
/*
|
||||||
* Destroy rasters...
|
* Destroy rasters...
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -97,7 +97,7 @@ CText::Unload(void)
|
||||||
wchar*
|
wchar*
|
||||||
CText::Get(const char *key)
|
CText::Get(const char *key)
|
||||||
{
|
{
|
||||||
#ifdef FIX_BUGS
|
#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
|
||||||
return keyArray.Search(key, data.chars);
|
return keyArray.Search(key, data.chars);
|
||||||
#else
|
#else
|
||||||
return keyArray.Search(key);
|
return keyArray.Search(key);
|
||||||
|
@ -201,7 +201,7 @@ CKeyArray::Unload(void)
|
||||||
void
|
void
|
||||||
CKeyArray::Update(wchar *chars)
|
CKeyArray::Update(wchar *chars)
|
||||||
{
|
{
|
||||||
#ifndef FIX_BUGS
|
#if !defined(FIX_BUGS) && !defined(FIX_BUGS_64)
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < numEntries; i++)
|
for(i = 0; i < numEntries; i++)
|
||||||
entries[i].value = (wchar*)((uint8*)chars + (uintptr)entries[i].value);
|
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*
|
wchar*
|
||||||
#ifdef FIX_BUGS
|
#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
|
||||||
CKeyArray::Search(const char *key, wchar *data)
|
CKeyArray::Search(const char *key, wchar *data)
|
||||||
#else
|
#else
|
||||||
CKeyArray::Search(const char *key)
|
CKeyArray::Search(const char *key)
|
||||||
|
@ -239,7 +239,7 @@ CKeyArray::Search(const char *key)
|
||||||
char errstr[25];
|
char errstr[25];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef FIX_BUGS
|
#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
|
||||||
found = BinarySearch(key, entries, 0, numEntries-1);
|
found = BinarySearch(key, entries, 0, numEntries-1);
|
||||||
if(found)
|
if(found)
|
||||||
return (wchar*)((uint8*)data + found->valueOffset);
|
return (wchar*)((uint8*)data + found->valueOffset);
|
||||||
|
|
|
@ -7,7 +7,7 @@ void TextCopy(wchar *dst, const wchar *src);
|
||||||
|
|
||||||
struct CKeyEntry
|
struct CKeyEntry
|
||||||
{
|
{
|
||||||
#ifdef FIX_BUGS
|
#if defined(FIX_BUGS) || defined(FIX_BUGS_64)
|
||||||
uint32 valueOffset;
|
uint32 valueOffset;
|
||||||
#else
|
#else
|
||||||
wchar *value;
|
wchar *value;
|
||||||
|
@ -30,7 +30,7 @@ public:
|
||||||
void Unload(void);
|
void Unload(void);
|
||||||
void Update(wchar *chars);
|
void Update(wchar *chars);
|
||||||
CKeyEntry *BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high);
|
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);
|
wchar *Search(const char *key, wchar *data);
|
||||||
#else
|
#else
|
||||||
wchar *Search(const char *key);
|
wchar *Search(const char *key);
|
||||||
|
|
Loading…
Reference in a new issue