Merge branch 'develop' of github.com:thecodingmachine/workadventure into use-tiled-objects
This commit is contained in:
@@ -15,14 +15,9 @@ export interface RoomRedirect {
|
||||
|
||||
export class Room {
|
||||
public readonly id: string;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
private readonly isPublic: boolean;
|
||||
private _authenticationMandatory: boolean = DISABLE_ANONYMOUS;
|
||||
private _iframeAuthentication?: string = OPID_LOGIN_SCREEN_PROVIDER;
|
||||
private _mapUrl: string | undefined;
|
||||
private instance: string | undefined;
|
||||
private readonly _search: URLSearchParams;
|
||||
private _contactPage: string | undefined;
|
||||
private _group: string | null = null;
|
||||
@@ -37,13 +32,6 @@ export class Room {
|
||||
if (this.id.startsWith("/")) {
|
||||
this.id = this.id.substr(1);
|
||||
}
|
||||
if (this.id.startsWith("_/") || this.id.startsWith("*/")) {
|
||||
this.isPublic = true;
|
||||
} else if (this.id.startsWith("@/")) {
|
||||
this.isPublic = false;
|
||||
} else {
|
||||
throw new Error("Invalid room ID");
|
||||
}
|
||||
|
||||
this._search = new URLSearchParams(roomUrl.search);
|
||||
}
|
||||
@@ -84,8 +72,10 @@ export class Room {
|
||||
|
||||
const currentRoom = new Room(baseUrl);
|
||||
let instance: string = "global";
|
||||
if (currentRoom.isPublic) {
|
||||
instance = currentRoom.getInstance();
|
||||
if (currentRoom.id.startsWith("_/") || currentRoom.id.startsWith("*/")) {
|
||||
const match = /[_*]\/([^/]+)\/.+/.exec(currentRoom.id);
|
||||
if (!match) throw new Error('Could not extract instance from "' + currentRoom.id + '"');
|
||||
instance = match[1];
|
||||
}
|
||||
|
||||
baseUrl.pathname = "/_/" + instance + "/" + absoluteExitSceneUrl.host + absoluteExitSceneUrl.pathname;
|
||||
@@ -151,31 +141,6 @@ export class Room {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instance name is:
|
||||
* - In a public URL: the second part of the URL ( _/[instance]/map.json)
|
||||
* - In a private URL: [organizationId/worldId]
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public getInstance(): string {
|
||||
if (this.instance !== undefined) {
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
if (this.isPublic) {
|
||||
const match = /[_*]\/([^/]+)\/.+/.exec(this.id);
|
||||
if (!match) throw new Error('Could not extract instance from "' + this.id + '"');
|
||||
this.instance = match[1];
|
||||
return this.instance;
|
||||
} else {
|
||||
const match = /@\/([^/]+)\/([^/]+)\/.+/.exec(this.id);
|
||||
if (!match) throw new Error('Could not extract instance from "' + this.id + '"');
|
||||
this.instance = match[1] + "/" + match[2];
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public isDisconnected(): boolean {
|
||||
const alone = this._search.get("alone");
|
||||
if (alone && alone !== "0" && alone.toLowerCase() !== "false") {
|
||||
|
||||
@@ -16,6 +16,7 @@ export enum GameMapProperties {
|
||||
JITSI_TRIGGER_MESSAGE = "jitsiTriggerMessage",
|
||||
JITSI_URL = "jitsiUrl",
|
||||
JITSI_WIDTH = "jitsiWidth",
|
||||
JITSI_NO_PREFIX = "jitsiNoPrefix",
|
||||
NAME = "name",
|
||||
OPEN_TAB = "openTab",
|
||||
OPEN_WEBSITE = "openWebsite",
|
||||
|
||||
@@ -79,7 +79,11 @@ export class GameMapPropertiesListener {
|
||||
});
|
||||
} else {
|
||||
const openJitsiRoomFunction = () => {
|
||||
const roomName = jitsiFactory.getRoomName(newValue.toString(), this.scene.instance);
|
||||
let addPrefix = true;
|
||||
if (allProps.get(GameMapProperties.JITSI_NO_PREFIX)) {
|
||||
addPrefix = false;
|
||||
}
|
||||
const roomName = jitsiFactory.getRoomName(newValue.toString(), this.scene.roomUrl, addPrefix);
|
||||
const jitsiUrl = allProps.get(GameMapProperties.JITSI_URL) as string | undefined;
|
||||
|
||||
if (JITSI_PRIVATE_MODE && !jitsiUrl) {
|
||||
|
||||
@@ -185,7 +185,6 @@ export class GameScene extends DirtyScene {
|
||||
private biggestAvailableAreaStoreUnsubscribe!: () => void;
|
||||
MapUrlFile: string;
|
||||
roomUrl: string;
|
||||
instance: string;
|
||||
|
||||
currentTick!: number;
|
||||
lastSentTick!: number; // The last tick at which a position was sent.
|
||||
@@ -234,7 +233,6 @@ export class GameScene extends DirtyScene {
|
||||
});
|
||||
this.Terrains = [];
|
||||
this.groups = new Map<number, Sprite>();
|
||||
this.instance = room.getInstance();
|
||||
|
||||
this.MapUrlFile = MapUrlFile;
|
||||
this.roomUrl = room.key;
|
||||
|
||||
@@ -9,4 +9,21 @@ export class StringUtils {
|
||||
}
|
||||
return { x: values[0], y: values[1] };
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a "short URL" hash of the string passed in parameter.
|
||||
*/
|
||||
public static shortHash = function (s: string): string {
|
||||
let hash = 0;
|
||||
const strLength = s.length;
|
||||
if (strLength === 0) {
|
||||
return "";
|
||||
}
|
||||
for (let i = 0; i < strLength; i++) {
|
||||
const c = s.charCodeAt(i);
|
||||
hash = (hash << 5) - hash + c;
|
||||
hash = hash & hash; // Convert to 32bit integer
|
||||
}
|
||||
return Math.abs(hash).toString(36);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { get } from "svelte/store";
|
||||
import CancelablePromise from "cancelable-promise";
|
||||
import { gameManager } from "../Phaser/Game/GameManager";
|
||||
import { jitsiParticipantsCountStore, userIsJitsiDominantSpeakerStore } from "../Stores/GameStore";
|
||||
import { StringUtils } from "../Utils/StringUtils";
|
||||
|
||||
interface jitsiConfigInterface {
|
||||
startWithAudioMuted: boolean;
|
||||
@@ -120,7 +121,7 @@ const slugify = (...args: (string | number)[]): string => {
|
||||
.replace(/[\u0300-\u036f]/g, "") // remove all previously split accents
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/[^a-z0-9 ]/g, "") // remove all chars not letters, numbers and spaces (to be replaced)
|
||||
.replace(/[^a-z0-9-_ ]/g, "") // remove all chars not letters, numbers, dash, underscores and spaces (to be replaced)
|
||||
.replace(/\s+/g, "-"); // separator
|
||||
};
|
||||
|
||||
@@ -135,8 +136,8 @@ class JitsiFactory {
|
||||
/**
|
||||
* Slugifies the room name and prepends the room name with the instance
|
||||
*/
|
||||
public getRoomName(roomName: string, instance: string): string {
|
||||
return slugify(instance.replace("/", "-") + "-" + roomName);
|
||||
public getRoomName(roomName: string, roomId: string, addPrefix: boolean): string {
|
||||
return slugify((addPrefix ? StringUtils.shortHash(roomId) + "-" : "") + roomName);
|
||||
}
|
||||
|
||||
public start(
|
||||
|
||||
@@ -8,7 +8,8 @@ const report: NonNullable<Translation["report"]> = {
|
||||
block: "Blockiere diesen Nutzer",
|
||||
},
|
||||
title: "Melden",
|
||||
content: "Verfasse eine Beschwerde an die Administratoren dieses Raums. Diese können den Nutzer anschließend bannen.",
|
||||
content:
|
||||
"Verfasse eine Beschwerde an die Administratoren dieses Raums. Diese können den Nutzer anschließend bannen.",
|
||||
message: {
|
||||
title: "Deine Nachricht: ",
|
||||
empty: "Bitte Text eingeben.",
|
||||
|
||||
Reference in New Issue
Block a user