From d1209f8d15c83a1d8d29beafc085d927be7d2bcd Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 5 Mar 2013 14:10:30 -0800 Subject: !! db.inc.php change !! Don't write over your own! This is the way the file should look. --- includes/db.inc.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/includes/db.inc.php b/includes/db.inc.php index 6cd3f01..e1db0ee 100644 --- a/includes/db.inc.php +++ b/includes/db.inc.php @@ -1,11 +1,6 @@ +?> \ No newline at end of file -- cgit v1.2.3 From 677b7454a37a0152f50d40993460d8f5a071e181 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 5 Mar 2013 14:17:08 -0800 Subject: Map editor 0.1! --- css/mapeditor.css | 10 ++ includes/mapclass.php | 14 ++- index.php | 4 + js/mapspecs.js | 14 ++- pages/mapeditor.php | 283 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 318 insertions(+), 7 deletions(-) create mode 100644 css/mapeditor.css create mode 100644 pages/mapeditor.php diff --git a/css/mapeditor.css b/css/mapeditor.css new file mode 100644 index 0000000..60a6e78 --- /dev/null +++ b/css/mapeditor.css @@ -0,0 +1,10 @@ + + + +.plusMinus { + float:left; + width:130px; + border:1px solid gray; + padding:2px; + margin:2px; +} \ No newline at end of file diff --git a/includes/mapclass.php b/includes/mapclass.php index 9e91d3f..bc5a6e5 100644 --- a/includes/mapclass.php +++ b/includes/mapclass.php @@ -43,8 +43,15 @@ class map { public function __construct($code = NULL, $mapID = NULL) { //TODO: Use new code by default. if ($mapID !== NULL) $this->ID = $mapID; - if ($code !== NULL) $this->applyMapFromOldCode($code); - //$this->applyMapFromCode($code); + if ($code !== NULL) { + $dimensions = explode('.', explode(':', $code)[0])[0]; + if (strpos($dimensions, 'x') == true) { + $this->applyMapFromOldCode($code); + } else { + $this->applyMapFromCode($code); + } + } + } public function applyMapFromOldCode($code) { @@ -218,8 +225,7 @@ class map { //Outputs the new code. public function getCode() { //If we already have the code on hand... - if ($this->code) - return $this->code; + //if ($this->code) return $this->code; //Otherwise we need to build the code: $headers[0] = $this->width; $headers[1] = $this->height; diff --git a/index.php b/index.php index 9a5f7d7..f909306 100644 --- a/index.php +++ b/index.php @@ -212,6 +212,10 @@ switch ($request) { require 'pages/chat.php'; break; + case "mapeditor": + require 'pages/mapeditor.php'; + break; + case "admin": if ($_SESSION['isAdmin'] == true) { require 'pages/admin.php'; diff --git a/js/mapspecs.js b/js/mapspecs.js index 2387a00..443ddfe 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -92,6 +92,12 @@ function grid_click(obj) { y = tmp[1]; x = tmp[2]; + + if(mapdata[mapid].editMap == true) { + mapClick(obj); + return; + } + //The users solution - prepare it if it's not started if (solution[mapid] == undefined) { getmapdata(mapid); @@ -838,7 +844,7 @@ var Tile = { "x" : "Single-Path-Rock"}; //Map as object. If target width is NULL or False, default width is used. -function mapAsHTML(map, targetWidth, demo) { +function mapAsHTML(map, targetWidth, mapEditor) { map.mapid = map.ID; //console.log("MapID:", map.mapid); @@ -872,9 +878,9 @@ function mapAsHTML(map, targetWidth, demo) { // GOAL WOULD BE THIS LINE INSTEAD.. As it's not retarded. //var idHandle = map.ID+','+x+','+y; - + //oldy is used for Position too... for now - if (type == 'o') { + if (type == 'o' || mapEditor == true) { mapgrid += "
"; mapgrid += "
"; } else { @@ -885,6 +891,8 @@ function mapAsHTML(map, targetWidth, demo) { } mapgrid += ''; + if (mapEditor == true) return mapgrid; + var r = ''; //TODO: Track down where that 1 pixel is comingfrom, width-1 is a hack. diff --git a/pages/mapeditor.php b/pages/mapeditor.php new file mode 100644 index 0000000..402f2d6 --- /dev/null +++ b/pages/mapeditor.php @@ -0,0 +1,283 @@ + $value) { + $map->$key = $value; + } + //Store the code in the object + $map->getCode(); + echo json_encode($map); + exit; +} + + +htmlHeader(array('stats', 'mapeditor'), 'Map Editor', + 'Map Editor', + array('dateformat')); + + +?> + + + + + +
+ +

Map Editor Beta

+ + +
+
+
+ Load Map: +
+ Load map by ID: + +
+ +
+ Load map by code: + +
+ +
+ +
+
+ +
+
+ +
+ Settings: +
+ Height: + +
+
+ Width: + +
+
+ Walls: + +
+ +
+ +
'; + continue; + } + + echo " +
+
+
"; + } + + ?> + + +
+
+ Edit Map: +
+ Loading... +
+
+
+
+ +
+
+
+ +
+
+ Returned map goes here. +
+
+ + + \ No newline at end of file -- cgit v1.2.3 From ce660e802d733171fd8370e0de5c3ce359648c1e Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 5 Mar 2013 14:18:19 -0800 Subject: Image for links to facebook and etc. --- images/linkdsp.png | Bin 0 -> 38111 bytes includes/header.php | 1 + 2 files changed, 1 insertion(+) create mode 100644 images/linkdsp.png diff --git a/images/linkdsp.png b/images/linkdsp.png new file mode 100644 index 0000000..118ae0b Binary files /dev/null and b/images/linkdsp.png differ diff --git a/includes/header.php b/includes/header.php index 136c2eb..44d028e 100644 --- a/includes/header.php +++ b/includes/header.php @@ -10,6 +10,7 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '', $scripts = a + \n"; -- cgit v1.2.3 From 474878d48788acd5ea8dafef095f3283478012ab Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 5 Mar 2013 14:23:02 -0800 Subject: Chat mute, chat in Title. --- css/chat.css | 8 ++++++-- pages/chat.php | 34 +++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/css/chat.css b/css/chat.css index 9608093..66cd086 100644 --- a/css/chat.css +++ b/css/chat.css @@ -3,7 +3,7 @@ font-family: 'Trebuchet MS1', 'Trebuchet MS', sans-serif; border: 1px solid gray; background-color:#999; - width: 700px; + width: 680px; margin: 7px; padding: 2px; border-radius: 10px; @@ -11,7 +11,11 @@ border-top-right-radius: 20px; } .chatButton { - margin: 4px; + margin: 0px; +} +.chatMute { + margin: 0px; + width: 15px; } #chatContainer { diff --git a/pages/chat.php b/pages/chat.php index 27122d8..f2d2231 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -45,6 +45,9 @@ function getChatDone(data) { var p; //our prep string var newChats = false; + var lastDisplay = ''; + var lastMessage = ''; + ////console.log('datalength', data.length); if (data.length < 3 || data == 'false') @@ -118,6 +121,8 @@ function getChatDone(data) { items.push('
' + p + '
'); newChats = true; } + lastDisplay = chat.displayName + lastMessage = chat.message if (chat.ID > 0) lastID = chat.ID; }); @@ -130,15 +135,18 @@ function getChatDone(data) { var atBottom = (elem.scrollTop() >= elem[0].scrollHeight - elem.outerHeight() - 1); $("#chatContainer").append(items.join('')); - + if (atBottom || firstGetChat) { $("#chatContainer").scrollTop($("#chatContainer")[0].scrollHeight); firstGetChat = false; } - soundManager.setVolume('charm', 20); - soundManager.setPan('charm', -60) - soundManager.setPosition('charm',150); - soundManager.play('charm'); + document.title = lastDisplay+': '+lastMessage.substring(0, 10)+'... Pathery Chat'; + if (!document.getElementById('chatMute').checked) { + soundManager.setVolume('charm', 20); + soundManager.setPan('charm', -60) + soundManager.setPosition('charm',150); + soundManager.play('charm'); + } } } @@ -150,10 +158,10 @@ function chatReplaceAndEncode(chat) { //Surround all URLs with a link var URLexp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; - chat = chat.replace(URLexp, "$1"); + chat = chat.replace(URLexp, "$1"); //Replace # in the URL with %23 - chat = chat.replace(//ig, ""); + chat = chat.replace(//ig, ""); return chat; } @@ -212,6 +220,10 @@ function htmlEncode(value){ } } +function setChatMute(value) { + savePref('chatMute', value); +} +
@@ -223,6 +235,14 @@ function htmlEncode(value){
+ + "; + ?> + -- cgit v1.2.3 From 46a83c128433c7c439af8137b026be832f32cb8d Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 5 Mar 2013 14:23:07 -0800 Subject: updated Homepage description. --- pages/home.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/home.php b/pages/home.php index 544b3fe..8c88d49 100644 --- a/pages/home.php +++ b/pages/home.php @@ -9,7 +9,7 @@ include_once ('./includes/constants.php'); htmlHeader( array('stats'), 'Pathery', - 'Compete to create the longest path possible. New maps every day!', + 'Path lengthening competition inspired by Tower Defense mazing concepts', array('scores', 'dateformat') ); -- cgit v1.2.3 From 62e2798a769d62e2c1714f3eb27b64f212d3fd65 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 5 Mar 2013 14:23:39 -0800 Subject: Whoops missed this for the mapeditor. --- css/maps.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/css/maps.css b/css/maps.css index 604192c..86a2f76 100644 --- a/css/maps.css +++ b/css/maps.css @@ -188,6 +188,13 @@ background-image: url(../images/OverlayTileFaceted20.png); } +.tileDisplay div { + float:left; + border:1px solid blue; + margin:2px; + width:36px; + height:36px; +} /* grid stuff */ -- cgit v1.2.3 From 81596179bcfc00b7428e238ab619875e7accb52a Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 6 Mar 2013 01:45:59 -0800 Subject: Chat Pretty Redirect --- index.php | 11 ++++++-- pages/chat.php | 3 +++ redirect.php | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 redirect.php diff --git a/index.php b/index.php index f909306..49793a0 100644 --- a/index.php +++ b/index.php @@ -99,8 +99,15 @@ switch ($request) { break; case "redirect": - $to = $_GET['to']; - DoRedirect("THIS URL COULD BE UNSAFE! Please confirm!
", $to, $duration = "8"); + //Whitelist things? + if (true) { + require('redirect.php'); + } else { + //Redirect instantly: + $to = $_GET['to']; + DoRedirect(NULL, $to, $duration = "0"); + } + exit; break; case "hometutorial": diff --git a/pages/chat.php b/pages/chat.php index f2d2231..d2198c7 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -162,6 +162,9 @@ function chatReplaceAndEncode(chat) { //Replace # in the URL with %23 chat = chat.replace(/
/ig, ""); + chat = chat.replace(//ig, ""); + //Making the bet that not all browsers do the same: + chat = chat.replace(//ig, ""); return chat; } diff --git a/redirect.php b/redirect.php new file mode 100644 index 0000000..e010d94 --- /dev/null +++ b/redirect.php @@ -0,0 +1,83 @@ + + + + +Pathery.com - Redirecting... + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From ab36b3bfff1b0c4d6e6398b1e968e41f436373b3 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 6 Mar 2013 01:47:20 -0800 Subject: mapeditor Go button fix. --- includes/mapclass.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ js/mapspecs.js | 2 +- pages/mapeditor.php | 3 ++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/includes/mapclass.php b/includes/mapclass.php index bc5a6e5..24b9108 100644 --- a/includes/mapclass.php +++ b/includes/mapclass.php @@ -253,6 +253,74 @@ class map { return $code; } + function getOldCode() { + + $code = ""; //The string to return to the database. + $index = 0; //The current number of tiles from the last tile saved. + + $code = $this->width.'x'.$this->height; + $code .= '.c'.$this->checkpoints; + $code .= '.r0'; //rocks... yeah. + $code .= '.w'.$this->walls; + $code .= '.t'.$this->teleports; + $code .= '.'.$this->name; + $code .= ".:"; + + $oldNames['o'] = 'o'; + + $oldNames['s'] = 's'; + $oldNames['s2'] = 'S'; + $oldNames['f'] = 'f'; + + $oldNames['c'] = 'a'; + $oldNames['c2'] = 'b'; + $oldNames['c3'] = 'c'; + $oldNames['c4'] = 'd'; + $oldNames['c5'] = 'e'; + + $oldNames['t'] = 't'; + $oldNames['t2'] = 'm'; + $oldNames['t3'] = 'g'; + $oldNames['t4'] = 'i'; + $oldNames['t5'] = 'k'; + + $oldNames['u'] = 'u'; + $oldNames['u2'] = 'n'; + $oldNames['u3'] = 'h'; + $oldNames['u4'] = 'j'; + $oldNames['u5'] = 'l'; + + $oldNames['x'] = 'x'; + $oldNames['x2'] = 'X'; + + $oldNames['r'] = 'r'; + $oldNames['r2'] = 'R'; + + for( $i = 0; $i < $this->height; $i++) { + for( $j = 0; $j < $this->width; $j++) { + if($this->tiles[$i][$j][0] != 'o') { + //As long as the tile is NOT open, embed it in the code. + + + $type = $this->tiles[$i][$j][0]; + $value = $this->tiles[$i][$j][1]; + if ($value <= 1) $value = ''; + + $code .= $index.$oldNames[$type.$value].'.'; + + + //$code .= $index.$mapMatrix[$i][$j].'.'; + //Start from 0 again. + $index = -1; + } + $index += 1; + } + } + + return $code; + + } + //Other "Magical" functions. public function __toString() { return $this->name; diff --git a/js/mapspecs.js b/js/mapspecs.js index 443ddfe..ecc5c9d 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -93,7 +93,7 @@ function grid_click(obj) { x = tmp[2]; - if(mapdata[mapid].editMap == true) { + if(typeof(mapdata[mapid]) == 'Object' && mapdata[mapid].editMap == true) { mapClick(obj); return; } diff --git a/pages/mapeditor.php b/pages/mapeditor.php index 402f2d6..87fef32 100644 --- a/pages/mapeditor.php +++ b/pages/mapeditor.php @@ -17,7 +17,8 @@ if ($_REQUEST['mapByMap']) { $map->$key = $value; } //Store the code in the object - $map->getCode(); + $code = $map->getOldCode(); + $map->code = $code; echo json_encode($map); exit; } -- cgit v1.2.3 From ee270d30697914e322dd1256e2e3e0b60df0ced5 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 6 Mar 2013 01:47:29 -0800 Subject: Share.php fix. --- pages/share.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pages/share.php b/pages/share.php index 098c281..3c72c11 100644 --- a/pages/share.php +++ b/pages/share.php @@ -6,10 +6,12 @@ htmlHeader(array('stats')); ID = 0; + +echo "
"; +echo ""; +echo "
"; //echo DisplayMap($map, 1, 'example', 1); -echo DisplayMap($map, 1); +//echo DisplayMap($map, 1); ?> + -- cgit v1.2.3