aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruruk2014-06-08 14:26:42 +0200
committeruruk2014-06-08 14:26:42 +0200
commit93010a840734507b84554ad47e50eec7db34a939 (patch)
tree73caba22788b181887e8b7fba7bb7af9ebf95946
parentba8bc2e40b94aa6055222550651452c3645c2515 (diff)
downloadscummvm-rg350-93010a840734507b84554ad47e50eec7db34a939.tar.gz
scummvm-rg350-93010a840734507b84554ad47e50eec7db34a939.tar.bz2
scummvm-rg350-93010a840734507b84554ad47e50eec7db34a939.zip
CGE2: Implement CGE2Engine::mapCross().
Rework Map during the process.
-rw-r--r--engines/cge2/hero.cpp20
-rw-r--r--engines/cge2/map.cpp4
-rw-r--r--engines/cge2/map.h2
3 files changed, 21 insertions, 5 deletions
diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp
index de0dc2688a..530ff11458 100644
--- a/engines/cge2/hero.cpp
+++ b/engines/cge2/hero.cpp
@@ -28,6 +28,7 @@
#include "cge2/hero.h"
#include "cge2/text.h"
#include "cge2/cge2_main.h"
+#include "cge2/map.h"
namespace CGE2 {
@@ -437,8 +438,23 @@ int Hero::mapCross(const V3D &a, const V3D &b) {
}
int CGE2Engine::mapCross(const V2D &a, const V2D &b) {
- warning("STUB: CGE2Engine::mapCross()");
- return 0;
+ int cnt = 0;
+ V2D *n0 = nullptr;
+ V2D *p = nullptr;
+ for (int i = 0; i < _map->size(); i++) {
+ V2D *n = _map->getCoord(i);
+ if (p) {
+ if (cross(a, b, *n0, *n))
+ ++cnt;
+
+ if (n == p)
+ p = nullptr;
+ } else {
+ p = n;
+ }
+ n0 = n;
+ }
+ return cnt;
}
void Hero::setCave(int c) {
diff --git a/engines/cge2/map.cpp b/engines/cge2/map.cpp
index 6dbf57f08d..8a9a5db4e2 100644
--- a/engines/cge2/map.cpp
+++ b/engines/cge2/map.cpp
@@ -86,8 +86,8 @@ int Map::size() {
return _container.size();
}
-V2D &Map::operator[](int idx) {
- return _container[idx];
+V2D *Map::getCoord(int idx) {
+ return &_container[idx];
}
} // End of namespace CGE2
diff --git a/engines/cge2/map.h b/engines/cge2/map.h
index 10448f0fd5..206479b929 100644
--- a/engines/cge2/map.h
+++ b/engines/cge2/map.h
@@ -47,7 +47,7 @@ public:
void clear();
void load(int scene);
int size();
- V2D &operator[](int idx);
+ V2D *getCoord(int idx);
};
} // End of namespace CGE2