diff --git a/src/client/canvas.ts b/src/client/canvas.ts index ebf467c..2762001 100644 --- a/src/client/canvas.ts +++ b/src/client/canvas.ts @@ -34,6 +34,8 @@ export class ViewCanvas { private _cursory = 0; private _relcursorx = 0; private _relcursory = 0; + private _screencursorx = 0; + private _screencursory = 0; private _dragging = false; @@ -79,11 +81,11 @@ export class ViewCanvas { this._relcursorx = Math.floor((this._cursorx - screenX) / pixelSize); this._relcursory = Math.floor((this._cursory - screenY) / pixelSize); - const snappedX = this._relcursorx * pixelSize + screenX; - const snappedY = this._relcursory * pixelSize + screenY; + this._screencursorx = this._relcursorx * pixelSize + screenX; + this._screencursory = this._relcursory * pixelSize + screenY; - this._cursor.style.top = `${snappedY + pixelSize / 2}px`; - this._cursor.style.left = `${snappedX + pixelSize / 2}px`; + this._cursor.style.top = `${this._screencursory + pixelSize / 2}px`; + this._cursor.style.left = `${this._screencursorx + pixelSize / 2}px`; this._cursor.style.transform = `scale(${pixelSize})`; } @@ -109,9 +111,7 @@ export class ViewCanvas { if (this._dragging) { this._posx -= offsetX; this._posy -= offsetY; - } - if (this._dragging) { this.moveCanvas(); this.moveCursor(); } diff --git a/src/server/index.ts b/src/server/index.ts index 9f74b8e..1a4db2f 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -50,7 +50,6 @@ passport.use( profile: any, done: Function, ) { - console.log(profile); process.nextTick(function () { return done(null, profile); }); @@ -114,12 +113,23 @@ const canvas = new Canvas(config.game.boardSize); const connections: Socket[] = []; const changes: CanvasRecord[] = []; +const dummyUser: IcyNetUser = { + id: 0, + username: 'placer', + display_name: 'placer', + uuid: 'placer', + accessToken: 'placer', +}; + io.use((socket, next) => sessionMiddleware(socket.request as any, {} as any, next as any), ); io.on('connection', (socket) => { const session = (socket.request as any).session; - const user = session?.passport?.user as IcyNetUser; + const user = + process.env.SKIP_LOGIN === 'true' + ? dummyUser + : (session?.passport?.user as IcyNetUser); connections.push(socket); socket.emit(