|
|
@ -5,9 +5,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
The client and server version strings MUST be the same!
|
|
|
|
The client and server version strings MUST be the same!
|
|
|
|
They can be used to force clients to hard refresh to load the latest client.
|
|
|
|
|
|
|
|
If the server gets updated it can be restarted, but if there are active clients (users' open browsers) they could be outdated and create issues.
|
|
|
|
If the server gets updated it can be restarted, but if there are active clients (users' open browsers) they could be outdated and create issues.
|
|
|
|
If the VERSION vars are mismatched they will send all clients in an infinite refresh loop. Make sure you update sketch.js before restarting server.js
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
var VERSION = "1.0";
|
|
|
|
var VERSION = "1.0";
|
|
|
|
|
|
|
|
|
|
|
@ -391,9 +389,12 @@ function setup() {
|
|
|
|
function (serverVersion, DATA) {
|
|
|
|
function (serverVersion, DATA) {
|
|
|
|
if (socket.id) {
|
|
|
|
if (socket.id) {
|
|
|
|
console.log("Welcome! Server version: " + serverVersion + " - client version " + VERSION);
|
|
|
|
console.log("Welcome! Server version: " + serverVersion + " - client version " + VERSION);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//this is before canvas so I have to html brutally
|
|
|
|
if (serverVersion != VERSION) {
|
|
|
|
if (serverVersion != VERSION) {
|
|
|
|
console.log("VERSION MISMATCH: FORCE RELOAD");
|
|
|
|
errorMessage = "VERSION MISMATCH: PLEASE HARD REFRESH";
|
|
|
|
location.reload(true);
|
|
|
|
document.body.innerHTML = errorMessage;
|
|
|
|
|
|
|
|
socket.disconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ROOMS = DATA.ROOMS;
|
|
|
|
ROOMS = DATA.ROOMS;
|
|
|
@ -568,8 +569,12 @@ function newGame() {
|
|
|
|
players = {};
|
|
|
|
players = {};
|
|
|
|
|
|
|
|
|
|
|
|
//ayay: connection lost while setting up character, just force a refresh
|
|
|
|
//ayay: connection lost while setting up character, just force a refresh
|
|
|
|
if (screen == "avatar" || screen == "user")
|
|
|
|
if (screen == "avatar" || screen == "user") {
|
|
|
|
location.reload();
|
|
|
|
screen = "error";
|
|
|
|
|
|
|
|
errorMessage = "SERVER RESTARTED: PLEASE REFRESH";
|
|
|
|
|
|
|
|
socket.disconnect();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bubbles = [];
|
|
|
|
bubbles = [];
|
|
|
|
|
|
|
|
|
|
|
@ -968,6 +973,7 @@ function newGame() {
|
|
|
|
|
|
|
|
|
|
|
|
//server forces refresh (on disconnect or to force load a new version of the client)
|
|
|
|
//server forces refresh (on disconnect or to force load a new version of the client)
|
|
|
|
socket.on('refresh', function () {
|
|
|
|
socket.on('refresh', function () {
|
|
|
|
|
|
|
|
socket.disconnect();
|
|
|
|
location.reload(true);
|
|
|
|
location.reload(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -1007,7 +1013,8 @@ function update() {
|
|
|
|
fill(UI_BG);
|
|
|
|
fill(UI_BG);
|
|
|
|
rect(0, 0, WIDTH, HEIGHT);
|
|
|
|
rect(0, 0, WIDTH, HEIGHT);
|
|
|
|
fill(LABEL_NEUTRAL_COLOR);
|
|
|
|
fill(LABEL_NEUTRAL_COLOR);
|
|
|
|
text(errorMessage, floor(WIDTH / 8), floor(HEIGHT / 8), WIDTH - floor(WIDTH / 4), HEIGHT - floor(HEIGHT / 4));
|
|
|
|
|
|
|
|
|
|
|
|
text(errorMessage, floor(WIDTH / 8), floor(HEIGHT / 8), WIDTH - floor(WIDTH / 4), HEIGHT - floor(HEIGHT / 4) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (screen == "game") {
|
|
|
|
else if (screen == "game") {
|
|
|
|
//draw a background
|
|
|
|
//draw a background
|
|
|
@ -1748,7 +1755,6 @@ function canvasReleased() {
|
|
|
|
//print("CLICK " + mouseButton);
|
|
|
|
//print("CLICK " + mouseButton);
|
|
|
|
|
|
|
|
|
|
|
|
if (screen == "error") {
|
|
|
|
if (screen == "error") {
|
|
|
|
location.reload();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nickName != "" && screen == "game" && mouseButton == RIGHT) {
|
|
|
|
else if (nickName != "" && screen == "game" && mouseButton == RIGHT) {
|
|
|
|
if (me.destinationX == me.x && me.destinationY == me.y)
|
|
|
|
if (me.destinationX == me.x && me.destinationY == me.y)
|
|
|
|