Index: ps/trunk/binaries/data/mods/public/gui/common/functions_utility.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/functions_utility.js +++ ps/trunk/binaries/data/mods/public/gui/common/functions_utility.js @@ -222,7 +222,7 @@ msgText.toLowerCase().indexOf(userName.toLowerCase()) == -1) return; - let timeNow = new Date().getTime(); + let timeNow = Date.now(); if (!g_LastNickNotification || timeNow > g_LastNickNotification + 3000) Engine.PlayUISound("audio/interface/ui/chat_alert.ogg", false); Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -2151,7 +2151,7 @@ if (Engine.ConfigDB_GetValue("user", "chat.timestamp") == "true") text = sprintf(translate("%(time)s %(message)s"), { "time": sprintf(translate("\\[%(time)s]"), { - "time": Engine.FormatMillisecondsIntoDateStringLocal(new Date().getTime(), translate("HH:mm")) + "time": Engine.FormatMillisecondsIntoDateStringLocal(Date.now(), translate("HH:mm")) }), "message": text }); Index: ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.js +++ ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.js @@ -14,8 +14,8 @@ */ var g_BackgroundLayerset; -var g_T0 = +(new Date()); -var g_LastTickTime = new Date(); +var g_T0 = Date.now(); +var g_LastTickTime = Date.now(); function init(initData, hotloadData) { @@ -60,7 +60,7 @@ var w = h * 16/9; var iw = h * 2; - var time = (new Date() - g_T0) / 1000; + var time = (Date.now() - g_T0) / 1000; var offset = g_BackgroundLayerset[i].offset(time, w); if (g_BackgroundLayerset[i].tiling) { @@ -113,8 +113,8 @@ function onTick() { - var now = new Date(); - var tickLength = new Date() - g_LastTickTime; + let now = Date.now(); + let tickLength = Date.now() - g_LastTickTime; g_LastTickTime = now; scrollBackgrounds(); Index: ps/trunk/binaries/data/mods/public/gui/session/input.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/input.js +++ ps/trunk/binaries/data/mods/public/gui/session/input.js @@ -878,8 +878,8 @@ case "hotkeydown": if (ev.hotkey.indexOf("selection.group.") == 0) { - var now = new Date(); - if ((now.getTime() - doublePressTimer < doublePressTime) && (ev.hotkey == prevHotkey)) + let now = Date.now(); + if (now - doublePressTimer < doublePressTime && ev.hotkey == prevHotkey) { if (ev.hotkey.indexOf("selection.group.select.") == 0) { @@ -892,7 +892,7 @@ var sptr = ev.hotkey.split("."); performGroup(sptr[2], sptr[3]); - doublePressTimer = now.getTime(); + doublePressTimer = now; prevHotkey = ev.hotkey; } } Index: ps/trunk/binaries/data/mods/public/gui/session/messages.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/messages.js +++ ps/trunk/binaries/data/mods/public/gui/session/messages.js @@ -908,7 +908,7 @@ let historical = { "txt": formatted, "timePrefix": sprintf(translate("\\[%(time)s]"), { - "time": Engine.FormatMillisecondsIntoDateStringLocal(new Date().getTime(), translate("HH:mm")) + "time": Engine.FormatMillisecondsIntoDateStringLocal(Date.now(), translate("HH:mm")) }), "filter": {} }; Index: ps/trunk/binaries/data/mods/public/gui/session/session.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/session.js +++ ps/trunk/binaries/data/mods/public/gui/session/session.js @@ -96,7 +96,7 @@ * Last time when onTick was called(). * Used for animating the main menu. */ -var lastTickTime = new Date(); +var g_LastTickTime = Date.now(); /** * Recalculate which units have their status bars shown with this frequency in milliseconds. @@ -737,9 +737,9 @@ if (!g_Settings) return; - let now = new Date(); - let tickLength = now - lastTickTime; - lastTickTime = now; + let now = Date.now(); + let tickLength = now - g_LastTickTime; + g_LastTickTime = now; handleNetMessages(); Index: ps/trunk/binaries/data/mods/public/maps/random/belgian_uplands.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/belgian_uplands.js +++ ps/trunk/binaries/data/mods/public/maps/random/belgian_uplands.js @@ -1,6 +1,6 @@ // Prepare progress calculation var timeArray = []; -timeArray.push(new Date().getTime()); +timeArray.push(Date.now()); // Importing rmgen libraries RMS.LoadLibrary("rmgen"); @@ -98,7 +98,7 @@ var minTerrainDistToBorder = 3; // Time check 1 -timeArray.push(new Date().getTime()); +timeArray.push(Date.now()); RMS.SetProgress(5); @@ -274,7 +274,7 @@ } // END THE GIANT WHILE LOOP // Time check 2 -timeArray.push(new Date().getTime()); +timeArray.push(Date.now()); RMS.SetProgress(60); @@ -403,7 +403,7 @@ } // Time check 3 -timeArray.push(new Date().getTime()); +timeArray.push(Date.now()); RMS.SetProgress(90); @@ -442,7 +442,7 @@ ExportMap(); // Time check 7 -timeArray.push(new Date().getTime()); +timeArray.push(Date.now()); // Calculate progress percentage with the time checks var generationTime = timeArray[timeArray.length - 1] - timeArray[0]; Index: ps/trunk/binaries/data/mods/public/maps/random/caledonian_meadows.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/caledonian_meadows.js +++ ps/trunk/binaries/data/mods/public/maps/random/caledonian_meadows.js @@ -3,10 +3,7 @@ InitMap(); -/** - * Start Timer - */ -let genStartTime = new Date().getTime(); +let genStartTime = Date.now(); /** * Returns an approximation of the heights of the tiles between the vertices, a tile centered heightmap @@ -181,7 +178,7 @@ max_x -= 1; max_y -= 1; } - + for (let x = 0; x < max_x; ++x) { vectorField.push([]); @@ -254,10 +251,10 @@ let validVertices = []; let r = 0.5 * (heightmap.length - 1); // Map center x/y as well as radius let avoidMap; - + if (avoidClass !== undefined) avoidMap = g_Map.tileClasses[avoidClass].inclusionCount; - + for (let x = minDistance; x < heightmap.length - minDistance; ++x) { for (let y = minDistance; y < heightmap[0].length - minDistance; ++y) @@ -284,7 +281,7 @@ placements.push(point); } if (tries != 0 && tries % 100 == 0) // Time Check - log(points.length + " points found after " + tries + " tries after " + ((new Date().getTime() - genStartTime) / 1000) + "s"); + log(points.length + " points found after " + tries + " tries after " + ((Date.now() - genStartTime) / 1000) + "s"); } return points; @@ -441,7 +438,7 @@ } } -log("Functions loaded after " + ((new Date().getTime() - genStartTime) / 1000) + "s"); // Time Check +log("Functions loaded after " + ((Date.now() - genStartTime) / 1000) + "s"); /** * Environment settings @@ -553,7 +550,7 @@ "textureHS": ["alpine_cliff_c"], "actorHS": [["actor|geology/highland1.xml"], 0.0] }); -log("Terrain shape generation and texture presets after " + ((new Date().getTime() - genStartTime) / 1000) + "s"); // Time Check +log("Terrain shape generation and texture presets after " + ((Date.now() - genStartTime) / 1000) + "s"); /** * Get start locations @@ -591,17 +588,17 @@ { let p1 = playerIDs[(pi + s) % playerIDs.length] - 1; let t1 = getPlayerTeam(p1); - + if (teams.indexOf(t1) === -1) continue; - + for (let pj = pi + 1; pj < playerIDs.length; ++pj) { let p2 = playerIDs[(pj + s) % playerIDs.length] - 1; let t2 = getPlayerTeam(p2); if (t2 != t1) continue; - + let l1 = startLocations[pi]; let l2 = startLocations[pj]; let dist = getDistance(l1.x, l1.y, l2.x, l2.y); @@ -609,7 +606,7 @@ maxTeamDist = dist; } } - + if (maxTeamDist < minDistance) { minDistance = maxTeamDist; @@ -625,7 +622,7 @@ } } -log("Start location chosen after " + ((new Date().getTime() - genStartTime) / 1000) + "s"); // Time Check +log("Start location chosen after " + ((Date.now() - genStartTime) / 1000) + "s"); RMS.SetProgress(30); /** @@ -641,7 +638,7 @@ pathPoints = pathPoints.concat(placeRandomPathToHeight(start, target, playerHeight, clPath)); } -log("Paths placed after " + ((new Date().getTime() - genStartTime) / 1000) + "s"); // Time Check +log("Paths placed after " + ((Date.now() - genStartTime) / 1000) + "s"); RMS.SetProgress(45); /** @@ -652,7 +649,7 @@ avoidPoints[i].dist = 30; let resourceSpots = getPointsByHeight({ "min": (heighLimits[3] + heighLimits[4]) / 2, "max": (heighLimits[5] + heighLimits[6]) / 2 }, avoidPoints, clPath); -log("Resource spots chosen after " + ((new Date().getTime() - genStartTime) / 1000) + "s"); // Time Check +log("Resource spots chosen after " + ((Date.now() - genStartTime) / 1000) + "s"); RMS.SetProgress(55); /** @@ -698,10 +695,10 @@ let x = areas[h][t].x; let y = areas[h][t].y; let slope = slopeMap[x][y]; - + if (slope > maxSlope[h]) maxSlope[h] = slope; - + if (slope < minSlope[h]) minSlope[h] = slope; } @@ -718,7 +715,7 @@ let y = areas[h][t].y; let actor = undefined; let texture = pickRandom(myBiome[h].texture); - + if (slopeMap[x][y] < 0.4 * (minSlope[h] + maxSlope[h])) { if (randBool(myBiome[h].actor[1])) @@ -730,15 +727,15 @@ if (randBool(myBiome[h].actorHS[1])) actor = pickRandom(myBiome[h].actorHS[0]); } - + g_Map.texture[x][y] = g_Map.getTextureID(texture); - + if (actor) placeObject(randFloat(x, x + 1), randFloat(y, y + 1), actor, 0, randFloat(0, 2 * PI)); } } -log("Terrain texture placement finished after " + ((new Date().getTime() - genStartTime) / 1000) + "s"); // Time Check +log("Terrain texture placement finished after " + ((Date.now() - genStartTime) / 1000) + "s"); RMS.SetProgress(80); /** @@ -770,7 +767,7 @@ /** * Stop Timer */ -log("Map generation finished after " + ((new Date().getTime() - genStartTime) / 1000) + "s"); +log("Map generation finished after " + ((Date.now() - genStartTime) / 1000) + "s"); /** * Export map data