From f70d3fd007ad2129adf413872260ecb461e96eb4 Mon Sep 17 00:00:00 2001
From: Manuel Herrmann <it@icetruck.de>
Date: Fri, 18 Sep 2015 17:35:38 +0200
Subject: [PATCH] debug grid to 5; walkable fix; walk paths closed

---
 .../view/signups/game1/js/svgUtils.js         |  58 ++++++++++++++++--
 .../signups/game1/maps/castle_entrance.svg    | Bin 583508 -> 583558 bytes
 .../view/signups/game1/test.html              |   2 +-
 3 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/registration-system/view/signups/game1/js/svgUtils.js b/registration-system/view/signups/game1/js/svgUtils.js
index 03b8f95..64b9ecf 100644
--- a/registration-system/view/signups/game1/js/svgUtils.js
+++ b/registration-system/view/signups/game1/js/svgUtils.js
@@ -20,12 +20,62 @@ function Path(svgPathData, offset) {
 	this.edges = [];
 
 	var currentPosition = [0,0];
+	var lastPosition = null;
 	if (!offset) offset = [0,0];
-	var relativeCommand = true;
 	var currentCommand = 'm';
 
 	var splitData = svgPathData.split(" ");
-	while (splitData.length > 0) {
+
+	for (var i = 0; i < splitData.length; ++i) {
+		var d = splitData[i];
+		var s = d.split(',');
+		var commandPart = s[0][0];
+		var commandPartInt = commandPart.charCodeAt(0);
+		var isNumber = (commandPartInt >= 48 && commandPartInt <= 57) || commandPart == '-' || commandPart == '+' || commandPart == '.';
+
+		if (isNumber) {
+			currentPosition = currentPosition.slice();
+			lastPosition = currentPosition.slice();
+			switch (currentCommand) {
+				case 'm':
+					currentPosition[0] = Number(s[0]) + offset[0];
+					currentPosition[1] = Number(s[1]) + offset[1];
+					currentCommand = 'l';
+					break;
+				case 'M':
+					currentPosition[0] = Number(s[0]) + offset[0];
+					currentPosition[1] = Number(s[1]) + offset[1];
+					currentCommand = 'L';
+					break;
+				case 'l':
+					currentPosition[0] += Number(s[0]);
+					currentPosition[1] += Number(s[1]);
+					this.edges.push([lastPosition.slice(), currentPosition.slice()]);
+					break;
+				case 'L':
+					currentPosition[0] = offset[0] + Number(s[0]);
+					currentPosition[1] = offset[1] + Number(s[1]);
+					this.edges.push([lastPosition.slice(), currentPosition.slice()]);
+					break;
+			}
+		} else {
+			switch (commandPart) {
+				case 'm':
+				case 'M':
+				case 'l':
+				case 'L':
+					currentCommand = commandPart;
+					break;
+				case 'z':
+					this.edges.push([this.edges[this.edges.length-1][1].slice(), this.edges[0][0].slice()]);
+					break;
+				default:
+					currentCommand = 'l'; // fallback
+			}
+		}
+	}
+
+	/*while (splitData.length > 0) {
 		var lastPosition = currentPosition.slice();
 
 		var part = splitData.shift();
@@ -57,11 +107,11 @@ function Path(svgPathData, offset) {
 					currentCommand = 'l'; // fallback
 			}
 			if (currentCommand == 'z') // close loop
-				this.edges.push([this.edges[this.edges.length-1][1], this.edges[0][0]]);
+	 			this.edges.push([this.edges[this.edges.length-1][1], this.edges[0][0]]);
 			if (rest.length > 0)
 				splitData.unshift(rest);
 		}
-	}
+	}*/
 }
 Path.prototype.lineIntersectionCount = function(fromX, fromY, x, y) {
 	var hitCount = 0;
diff --git a/registration-system/view/signups/game1/maps/castle_entrance.svg b/registration-system/view/signups/game1/maps/castle_entrance.svg
index 49512a392d345d4e4a27c45bd87b936e4f82fc1e..44bbf7d30207b6b6409bf37c8dae780d5c96773e 100644
GIT binary patch
delta 495
zcmZXPF-rq66vw$(?O_FxqT&`#T;wjiT#~zs*r6bTR6#`0Rcf)Nv`X!uT^s}z<ist4
z9sCGxw}^{d1r>2|6-PgUgVF1if`K1N-uu5_$lKHO$@BE>70U2{2;86m9FE)Qw2h3Y
zjnMsBUV;GWd4V;Ie^;em-7jwKmF9{EIg3j0iTl5Gn6n(g2z8~9uDU))i$)NAoTCN9
zkg5=(sgZK2vQutq18}NVLL?9ke)mar9iof@YV`t*pWcN?GoVRn1~o&PbaWS*@AK-l
zV=fKXwi?w^W3IkiS9>?<akX}n#wy!1XQR%eIg-j!Ujp$YWz1&81tD=ujlP)cgB$tf
z0*$IK=FHep{56cXb5;$z03LDufZ0L{A_5RTE@H4f;xUhN><GeqDQ)T!pdMq`>7M#3
ze_3He(&KhK70A9yPp}ELli0iR#L01-(t>WB<2b72$-D7P@7fEt6#h<6sLN0DAu4~E
GU#TCw@`Pys

delta 294
zcmZY1ze~eF90hRlZK{WK&_TpSV!Ecs{p{t`4uUucZvF!y7K~ac>QG$;TL>APPFw`@
z2k3U2LvT_s1Y8`Q#J@t**$1EHJ$Tn;`{TX+bPKMg-sx2i;~X5D13XVQg=A8MT=;X|
zG|9=)SsV@fYw@V(Qz00pO#a(0dVWYTS5k6m9#YtLr2R=@%W<h@#E=YD4bEWM9A>Zr
zOiY`l)*u=sgXFTmUq74Q6c)!t2DL`btu<>iwOLza=ySu&S7_a#=I#~knEMJn+TAzQ
za&_z}BCrxn(}3Vm39Y@3&<aZ?x-#f!OcY_-qe>Ip)s*vqV@9Ml$0gcB!|42=%P2F|
Q4fyuEM2!Voe4&@-9~UfKp#T5?

diff --git a/registration-system/view/signups/game1/test.html b/registration-system/view/signups/game1/test.html
index 696a405..5b7d7c6 100644
--- a/registration-system/view/signups/game1/test.html
+++ b/registration-system/view/signups/game1/test.html
@@ -65,7 +65,7 @@
     var game = new Game({
         startMap: maps[UrlComponents.getValueOf('map') || 0],
         showEventLayers: UrlComponents.isSet('showEventLayers'),
-        pathFindingGridSize: UrlComponents.isSet('verbosePF') ? 18 : 5,
+        pathFindingGridSize: UrlComponents.isSet('verbosePF') ? 5 : 5,
         verbosePathFinder: UrlComponents.isSet('verbosePF'),
         usePathFinding: true,
         size: [800, 600]
-- 
GitLab