summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/maps.php23
-rw-r--r--pages/chat.php9
-rw-r--r--pages/mapeditor.php2
3 files changed, 20 insertions, 14 deletions
diff --git a/includes/maps.php b/includes/maps.php
index 412068e..5ccb033 100644
--- a/includes/maps.php
+++ b/includes/maps.php
@@ -347,10 +347,13 @@ function DisplayMapThumbnail($map, $link = false) {
//Generates map
-function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1, $mapName = '') {
-
+function GenerateMap($width, $height, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1, $mapName = '') {
+ //Prevent server crash by limiting the number of rows/cols
+ $width = ($width <= 50 ? $width : 19);
+ $height = ($height <= 50 ? $height : 9);
+
if ($numBlocks == -1)
- $numBlocks = Rand(7, (int)($rows * $cols) * .12);
+ $numBlocks = Rand(7, (int)($width * $height) * .12);
//Checkpoints and teleports.
if ($cp == -1)
$cp = rand(0, 5);
@@ -361,11 +364,11 @@ function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp =
//== Possibility of inf loop here, if the map is too small.
do {
- $randvalue = rand(1, ($rows * $cols));
+ $randvalue = rand(1, ($width * $height));
//As long as it isn't the first, or last column.
//if ((($randvalue +1) % ($rows)) > 1) {
//As long as it isn't in the first, 2nd, last and 2nd to last column.
- if ((($randvalue +2) % ($rows)) > 3) {
+ if ((($randvalue +2) % ($width)) > 3) {
$unique[] = $randvalue;
$unique = array_unique($unique);
$unique = array_values($unique);
@@ -397,15 +400,15 @@ function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp =
do {
$p = -1;
//Begin loop to populate grid.
- for( $y = 1; $y <= $cols; $y++) { //Number of Columns
- for( $x = 0; $x < $rows; $x++) { //Number of Rows
+ for( $y = 1; $y <= $height; $y++) { //Number of Rows
+ for( $x = 0; $x < $width; $x++) { //Number of Columns
$p++;
//Start and Finish squares.
if ($x == 0) {
//if ($x == 0 AND $y == 1) {
//if ($x == 0 AND rand(1,3) == 1) {
$grid[$y][$x] = "s";
- } elseif ($x == $rows - 1) {
+ } elseif ($x == $width - 1) {
//} elseif ($x == $rows - 1 AND $y == intval(($cols + 1) * .5) ) {
//} elseif ($x == $rows - 1 AND rand(1,3) == 1) {
$grid[$y][$x] = "f";
@@ -433,8 +436,8 @@ function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp =
} //Rows
} //Cols
//Fill $grid[0] with header information
- $grid[0][0] = $rows;
- $grid[0][1] = $cols;
+ $grid[0][0] = $width;
+ $grid[0][1] = $height;
$grid[0][2] = count($checkpoint);
$grid[0][3] = $rocks;
$grid[0][4] = $numBlocks;
diff --git a/pages/chat.php b/pages/chat.php
index 4a14a8d..f55476f 100644
--- a/pages/chat.php
+++ b/pages/chat.php
@@ -177,11 +177,12 @@ function chatReplaceAndEncode(chat) {
//Surround all URLs with a <a> link
var URLexp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
- chat = chat.replace(URLexp, "<a href='redirect?to=$1' target='_blank' onclick='return doNothingWhenClickingLinks();'>$1</a>");
+ chat = chat.replace(URLexp, "<a href='redirect?to=$1' target='_blank' onclick='return doNothingWhenClickingLinks(this);'>$1</a>");
- //Replace # in the URL with %23
+ //Replace # with %23, & with %26, ? with %3F
chat = chat.replace(/<a href='redirect\?to=(.*?)(#)(.*?)' target='_blank'/ig, "<a href='redirect?to=$1%23$3' target='_blank'");
chat = chat.replace(/<a href='redirect\?to=(.*?)(&amp;)(.*?)' target='_blank'/ig, "<a href='redirect?to=$1%26$3' target='_blank'");
+ chat = chat.replace(/<a href='redirect\?to=(.*?)(\?)(.*?)' target='_blank'/ig, "<a href='redirect?to=$1%3F$3' target='_blank'");
//Making the bet that not all browsers do the same:
chat = chat.replace(/<a href='redirect\?to=(.*?)(&)(.*?)' target='_blank'/ig, "<a href='redirect?to=$1%26$3' target='_blank'");
@@ -284,9 +285,9 @@ function htmlEncode(value){
}
}
-function doNothingWhenClickingLinks()
+function doNothingWhenClickingLinks(self)
{
- return false;
+ return !$(self).closest('.spoiler').length;
}
//Code for checking if the window is currently visible or not
diff --git a/pages/mapeditor.php b/pages/mapeditor.php
index b86aa14..9e1e57c 100644
--- a/pages/mapeditor.php
+++ b/pages/mapeditor.php
@@ -180,6 +180,8 @@ function updateName() {
}
function changeDimensions(width, height) {
+ width = Math.Min(width, 50);
+ height = Math.Min(height, 50);
testMap.tiles = constructTiles(width, height, testMap);
//testMap.tiles[0][3] = Array('s');