From 93010a840734507b84554ad47e50eec7db34a939 Mon Sep 17 00:00:00 2001 From: uruk Date: Sun, 8 Jun 2014 14:26:42 +0200 Subject: CGE2: Implement CGE2Engine::mapCross(). Rework Map during the process. --- engines/cge2/hero.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'engines/cge2/hero.cpp') 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) { -- cgit v1.2.3