mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 18:30:00 +00:00
Fix build without FIX_BUGS, divide to 0 fixes
This commit is contained in:
parent
5d4917a5d7
commit
542a5393ac
|
@ -238,12 +238,16 @@ 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, 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 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
|
||||||
#define FIX_HIGH_FPS_BUGS_ON_FRONTEND
|
#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
|
// Just debug menu entries
|
||||||
#ifdef DEBUGMENU
|
#ifdef DEBUGMENU
|
||||||
#define RELOADABLES // some debug menu options to reload TXD files
|
#define RELOADABLES // some debug menu options to reload TXD files
|
||||||
|
|
|
@ -883,9 +883,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){
|
||||||
|
@ -1054,7 +1058,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;
|
||||||
|
@ -1084,7 +1094,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){
|
||||||
|
@ -1112,7 +1127,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){
|
||||||
|
@ -1140,7 +1160,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);
|
||||||
|
@ -1178,7 +1203,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;
|
||||||
|
@ -1196,7 +1226,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);
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +264,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;
|
||||||
|
@ -277,7 +278,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;
|
||||||
|
@ -483,7 +484,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...
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -111,14 +111,14 @@ wchar*
|
||||||
CText::Get(const char *key)
|
CText::Get(const char *key)
|
||||||
{
|
{
|
||||||
uint8 result = false;
|
uint8 result = false;
|
||||||
#ifdef FIX_BUGS
|
#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
|
||||||
wchar *outstr = keyArray.Search(key, data.chars, &result);
|
wchar *outstr = keyArray.Search(key, data.chars, &result);
|
||||||
#else
|
#else
|
||||||
wchar *outstr = keyArray.Search(key, &result);
|
wchar *outstr = keyArray.Search(key, &result);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!result && bHasMissionTextOffsets && bIsMissionTextLoaded)
|
if (!result && bHasMissionTextOffsets && bIsMissionTextLoaded)
|
||||||
#ifdef FIX_BUGS
|
#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
|
||||||
outstr = mission_keyArray.Search(key, mission_data.chars, &result);
|
outstr = mission_keyArray.Search(key, mission_data.chars, &result);
|
||||||
#else
|
#else
|
||||||
outstr = mission_keyArray.Search(key, &result);
|
outstr = mission_keyArray.Search(key, &result);
|
||||||
|
@ -340,7 +340,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);
|
||||||
|
@ -368,7 +368,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, uint8 *result)
|
CKeyArray::Search(const char *key, wchar *data, uint8 *result)
|
||||||
#else
|
#else
|
||||||
CKeyArray::Search(const char *key, uint8 *result)
|
CKeyArray::Search(const char *key, uint8 *result)
|
||||||
|
@ -378,7 +378,7 @@ CKeyArray::Search(const char *key, uint8 *result)
|
||||||
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) {
|
||||||
*result = true;
|
*result = true;
|
||||||
|
|
|
@ -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, uint8 *result);
|
wchar *Search(const char *key, wchar *data, uint8 *result);
|
||||||
#else
|
#else
|
||||||
wchar *Search(const char *key, uint8* result);
|
wchar *Search(const char *key, uint8* result);
|
||||||
|
|
Loading…
Reference in a new issue