summaryrefslogtreecommitdiffstats
path: root/src/entities/Entity.cpp
diff options
context:
space:
mode:
authorFire_Head <Fire-Head@users.noreply.github.com>2019-07-11 02:48:36 +0200
committerGitHub <noreply@github.com>2019-07-11 02:48:36 +0200
commitaa449b6fe162d8960351c5fe164a9120b8572652 (patch)
treefa82496d356ac2b77ffa1ab00684b0150907f009 /src/entities/Entity.cpp
parentfixfixfix (diff)
parentMerge pull request #129 from erorcun/erorcun (diff)
downloadre3-aa449b6fe162d8960351c5fe164a9120b8572652.tar
re3-aa449b6fe162d8960351c5fe164a9120b8572652.tar.gz
re3-aa449b6fe162d8960351c5fe164a9120b8572652.tar.bz2
re3-aa449b6fe162d8960351c5fe164a9120b8572652.tar.lz
re3-aa449b6fe162d8960351c5fe164a9120b8572652.tar.xz
re3-aa449b6fe162d8960351c5fe164a9120b8572652.tar.zst
re3-aa449b6fe162d8960351c5fe164a9120b8572652.zip
Diffstat (limited to 'src/entities/Entity.cpp')
-rw-r--r--src/entities/Entity.cpp60
1 files changed, 38 insertions, 22 deletions
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index fac7f17f..10677bdf 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -632,7 +632,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true;
else
lightFlickering = true;
- if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed) & 3)
+ if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3)
lightOn = true;
break;
case LIGHT_FLICKER_NIGHT:
@@ -641,7 +641,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true;
else
lightFlickering = true;
- if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed) & 3)
+ if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3)
lightOn = true;
}
break;
@@ -680,7 +680,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true;
else
lightFlickering = true;
- if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed*8) & 3)
+ if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3)
lightOn = true;
}
break;
@@ -693,7 +693,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true;
else
lightFlickering = true;
- if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed*8) & 3)
+ if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3)
lightOn = true;
}
}
@@ -806,17 +806,17 @@ CEntity::ModifyMatrixForTreeInWind(void)
}else if(CWeather::Wind >= 0.2){
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
f = (t & 0xFFF)/(float)0x1000;
- flutter = sin(f * 6.28f);
+ flutter = Sin(f * 6.28f);
strength = 0.008f;
}else{
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
f = (t & 0xFFF)/(float)0x1000;
- flutter = sin(f * 6.28f);
+ flutter = Sin(f * 6.28f);
strength = 0.005f;
}
- mat.GetUp()->x = strength * flutter;
- mat.GetUp()->y = mat.GetUp()->x;
+ mat.GetUp().x = strength * flutter;
+ mat.GetUp().y = mat.GetUp().x;
mat.UpdateRW();
UpdateRwFrame();
@@ -847,7 +847,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
else
strength = 0.66f;
- t = ((int)(GetMatrix().GetPosition()->x + GetMatrix().GetPosition()->y) << 10) + 16*CTimer::GetTimeInMilliseconds();
+ t = ((int)(GetMatrix().GetPosition().x + GetMatrix().GetPosition().y) << 10) + 16*CTimer::GetTimeInMilliseconds();
f = (t & 0x7FF)/(float)0x800;
flutter = f * BannerWindTabel[(t>>11)+1 & 0x1F] +
(1.0f - f) * BannerWindTabel[(t>>11) & 0x1F];
@@ -857,7 +857,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
right.z = 0.0f;
right.Normalise();
up = right * flutter;
- up.z = sqrt(sq(1.0f) - sq(flutter));
+ up.z = Sqrt(sq(1.0f) - sq(flutter));
GetRight() = CrossProduct(GetForward(), up);
GetUp() = up;
@@ -865,10 +865,35 @@ CEntity::ModifyMatrixForBannerInWind(void)
UpdateRwFrame();
}
+class CEntity_ : public CEntity
+{
+public:
+ CEntity *ctor(void) { return ::new (this) CEntity(); }
+ void dtor(void) { this->CEntity::~CEntity(); }
+ void Add_(void) { CEntity::Add(); }
+ void Remove_(void) { CEntity::Remove(); }
+ void SetModelIndex_(uint32 i) { CEntity::SetModelIndex(i); }
+ void CreateRwObject_(void) { CEntity::CreateRwObject(); }
+ void DeleteRwObject_(void) { CEntity::DeleteRwObject(); }
+ CRect GetBoundRect_(void) { return CEntity::GetBoundRect(); }
+ void PreRender_(void) { CEntity::PreRender(); }
+ void Render_(void) { CEntity::Render(); }
+ bool SetupLighting_(void) { return CEntity::SetupLighting(); }
+};
+
STARTPATCHES
- InjectHook(0x473C30, &CEntity::ctor, PATCH_JUMP);
- InjectHook(0x473E40, &CEntity::dtor, PATCH_JUMP);
- InjectHook(0x473E70, &CEntity::SetModelIndex_, PATCH_JUMP);
+ InjectHook(0x473C30, &CEntity_::ctor, PATCH_JUMP);
+ InjectHook(0x473E40, &CEntity_::dtor, PATCH_JUMP);
+ InjectHook(0x473E70, &CEntity_::SetModelIndex_, PATCH_JUMP);
+ InjectHook(0x475080, &CEntity_::Add_, PATCH_JUMP);
+ InjectHook(0x475310, &CEntity_::Remove_, PATCH_JUMP);
+ InjectHook(0x473EA0, &CEntity_::CreateRwObject_, PATCH_JUMP);
+ InjectHook(0x473F90, &CEntity_::DeleteRwObject_, PATCH_JUMP);
+ InjectHook(0x474000, &CEntity_::GetBoundRect_, PATCH_JUMP);
+ InjectHook(0x474350, &CEntity_::PreRender_, PATCH_JUMP);
+ InjectHook(0x474BD0, &CEntity_::Render_, PATCH_JUMP);
+ InjectHook(0x4A7C60, &CEntity_::SetupLighting_, PATCH_JUMP);
+
InjectHook(0x4742C0, (void (CEntity::*)(CVector&))&CEntity::GetBoundCentre, PATCH_JUMP);
InjectHook(0x474310, &CEntity::GetBoundRadius, PATCH_JUMP);
InjectHook(0x474C10, &CEntity::GetIsTouching, PATCH_JUMP);
@@ -889,13 +914,4 @@ STARTPATCHES
InjectHook(0x475670, &CEntity::ModifyMatrixForTreeInWind, PATCH_JUMP);
InjectHook(0x475830, &CEntity::ModifyMatrixForBannerInWind, PATCH_JUMP);
InjectHook(0x4FA530, &CEntity::ProcessLightsForEntity, PATCH_JUMP);
-
- InjectHook(0x475080, &CEntity::Add_, PATCH_JUMP);
- InjectHook(0x475310, &CEntity::Remove_, PATCH_JUMP);
- InjectHook(0x473EA0, &CEntity::CreateRwObject_, PATCH_JUMP);
- InjectHook(0x473F90, &CEntity::DeleteRwObject_, PATCH_JUMP);
- InjectHook(0x474000, &CEntity::GetBoundRect_, PATCH_JUMP);
- InjectHook(0x474350, &CEntity::PreRender_, PATCH_JUMP);
- InjectHook(0x474BD0, &CEntity::Render_, PATCH_JUMP);
- InjectHook(0x4A7C60, &CEntity::SetupLighting_, PATCH_JUMP);
ENDPATCHES