summaryrefslogtreecommitdiffstats
path: root/src/Placeable.cpp
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-05-15 16:52:37 +0200
committeraap <aap@papnet.eu>2019-05-15 16:52:37 +0200
commit600bf0351476a5a21aabb5429132ddf7f52ac0b9 (patch)
treed8e48b3a581679e33830fb7c98ed69e1e242e2c2 /src/Placeable.cpp
downloadre3-600bf0351476a5a21aabb5429132ddf7f52ac0b9.tar
re3-600bf0351476a5a21aabb5429132ddf7f52ac0b9.tar.gz
re3-600bf0351476a5a21aabb5429132ddf7f52ac0b9.tar.bz2
re3-600bf0351476a5a21aabb5429132ddf7f52ac0b9.tar.lz
re3-600bf0351476a5a21aabb5429132ddf7f52ac0b9.tar.xz
re3-600bf0351476a5a21aabb5429132ddf7f52ac0b9.tar.zst
re3-600bf0351476a5a21aabb5429132ddf7f52ac0b9.zip
Diffstat (limited to 'src/Placeable.cpp')
-rw-r--r--src/Placeable.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/Placeable.cpp b/src/Placeable.cpp
new file mode 100644
index 00000000..43708d3e
--- /dev/null
+++ b/src/Placeable.cpp
@@ -0,0 +1,81 @@
+#include "common.h"
+#include "Placeable.h"
+#include "patcher.h"
+
+CPlaceable::CPlaceable(void)
+{
+ m_matrix.SetScale(1.0f);
+}
+
+CPlaceable::~CPlaceable(void) { }
+
+void
+CPlaceable::SetHeading(float angle)
+{
+ CVector pos = GetPosition();
+ m_matrix.SetRotateZ(angle);
+ GetPosition() += pos;
+}
+
+bool
+CPlaceable::IsWithinArea(float x1, float y1, float x2, float y2)
+{
+ float x, xmin, xmax;
+ float y, ymin, ymax;
+ xmin = x1;
+ xmax = x2;
+ ymin = y1;
+ ymax = y2;
+ if(x2 > x1){
+ xmin = x2;
+ xmax = x1;
+ }
+ if(y2 > y1){
+ ymin = y2;
+ ymax = y1;
+ }
+ x = GetPosition().x;
+ y = GetPosition().y;
+ return xmin <= x && x <= xmax &&
+ ymin <= y && y <= ymax;
+}
+
+bool
+CPlaceable::IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2)
+{
+ float x, xmin, xmax;
+ float y, ymin, ymax;
+ float z, zmin, zmax;
+ xmin = x1;
+ xmax = x2;
+ ymin = y1;
+ ymax = y2;
+ zmin = z1;
+ zmax = z2;
+ if(x2 > x1){
+ xmin = x2;
+ xmax = x1;
+ }
+ if(y2 > y1){
+ ymin = y2;
+ ymax = y1;
+ }
+ if(z2 > z1){
+ zmin = z2;
+ zmax = z1;
+ }
+ x = GetPosition().x;
+ y = GetPosition().y;
+ z = GetPosition().z;
+ return xmin <= x && x <= xmax &&
+ ymin <= y && y <= ymax &&
+ zmin <= z && z <= zmax;
+}
+
+STARTPATCHES
+ InjectHook(0x49F9A0, &CPlaceable::ctor, PATCH_JUMP);
+ InjectHook(0x49F9E0, &CPlaceable::dtor, PATCH_JUMP);
+ InjectHook(0x49FA00, &CPlaceable::SetHeading, PATCH_JUMP);
+ InjectHook(0x49FA50, (bool (CPlaceable::*)(float, float, float, float))&CPlaceable::IsWithinArea, PATCH_JUMP);
+ InjectHook(0x49FAF0, (bool (CPlaceable::*)(float, float, float, float, float, float))&CPlaceable::IsWithinArea, PATCH_JUMP);
+ENDPATCHES