diff --git a/packages/api/src/nitro/room/IRoomCreator.ts b/packages/api/src/nitro/room/IRoomCreator.ts index 4cc3b07..52b02fa 100644 --- a/packages/api/src/nitro/room/IRoomCreator.ts +++ b/packages/api/src/nitro/room/IRoomCreator.ts @@ -37,7 +37,7 @@ export interface IRoomCreator updateRoomObjectWallExpiration(roomId: number, objectId: number, expires: number): boolean; rollRoomObjectFloor(roomId: number, objectId: number, location: IVector3D, targetLocation: IVector3D): void; addRoomObjectUser(roomId: number, objectId: number, location: IVector3D, direction: IVector3D, headDirection: number, type: number, figure: string): boolean; - updateRoomObjectUserLocation(roomId: number, objectId: number, location: IVector3D, targetLocation: IVector3D, canStandUp?: boolean, baseY?: number, direction?: IVector3D, headDirection?: number): boolean; + updateRoomObjectUserLocation(roomId: number, objectId: number, location: IVector3D, targetLocation: IVector3D, canStandUp?: boolean, baseY?: number, direction?: IVector3D, headDirection?: number, skipLocationFix?: boolean): boolean; updateRoomObjectUserAction(roomId: number, objectId: number, action: string, value: number, parameter?: string): boolean; updateRoomObjectUserFigure(roomId: number, objectId: number, figure: string, gender?: string, subType?: string, isRiding?: boolean): boolean; updateRoomObjectUserFlatControl(roomId: number, objectId: number, level: string): boolean; diff --git a/packages/api/src/nitro/room/IRoomEngine.ts b/packages/api/src/nitro/room/IRoomEngine.ts index b3c879d..f153dc0 100644 --- a/packages/api/src/nitro/room/IRoomEngine.ts +++ b/packages/api/src/nitro/room/IRoomEngine.ts @@ -45,7 +45,7 @@ export interface IRoomEngine getFurnitureWallIcon(typeId: number, listener: IGetImageListener, extras?: string): IImageResult; updateRoomObjectWallLocation(roomId: number, objectId: number, location: IVector3D): boolean; addRoomObjectUser(roomId: number, objectId: number, location: IVector3D, direction: IVector3D, headDirection: number, type: number, figure: string): boolean; - updateRoomObjectUserLocation(roomId: number, objectId: number, location: IVector3D, targetLocation: IVector3D, canStandUp?: boolean, baseY?: number, direction?: IVector3D, headDirection?: number): boolean; + updateRoomObjectUserLocation(roomId: number, objectId: number, location: IVector3D, targetLocation: IVector3D, canStandUp?: boolean, baseY?: number, direction?: IVector3D, headDirection?: number, skipLocationFix?: boolean): boolean; addFurnitureFloor(roomId: number, id: number, typeId: number, location: IVector3D, direction: IVector3D, state: number, objectData: IObjectData, extra?: number, expires?: number, usagePolicy?: number, ownerId?: number, ownerName?: string, synchronized?: boolean, realRoomObject?: boolean, sizeZ?: number): boolean; addFurnitureFloorByTypeName(roomId: number, id: number, typeName: string, location: IVector3D, direction: IVector3D, state: number, objectData: IObjectData, extra?: number, expires?: number, usagePolicy?: number, ownerId?: number, ownerName?: string, synchronized?: boolean, realRoomObject?: boolean, sizeZ?: number): boolean; addFurnitureWall(roomId: number, id: number, typeId: number, location: IVector3D, direction: IVector3D, state: number, extra: string, expires?: number, usagePolicy?: number, ownerId?: number, ownerName?: string, realRoomObject?: boolean): boolean; diff --git a/packages/room/src/RoomEngine.ts b/packages/room/src/RoomEngine.ts index 6726236..ce53d69 100644 --- a/packages/room/src/RoomEngine.ts +++ b/packages/room/src/RoomEngine.ts @@ -1884,7 +1884,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService return true; } - public updateRoomObjectUserLocation(roomId: number, objectId: number, location: IVector3D, targetLocation: IVector3D, canStandUp: boolean = false, baseY: number = 0, direction: IVector3D = null, headDirection: number = NaN): boolean + public updateRoomObjectUserLocation(roomId: number, objectId: number, location: IVector3D, targetLocation: IVector3D, canStandUp: boolean = false, baseY: number = 0, direction: IVector3D = null, headDirection: number = NaN, skipLocationFix: boolean = false): boolean { const object = this.getRoomObjectUser(roomId, objectId); @@ -1896,7 +1896,10 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService if(isNaN(headDirection)) headDirection = object.model.getValue(RoomObjectVariable.HEAD_DIRECTION); - object.processUpdateMessage(new ObjectAvatarUpdateMessage(this.fixedUserLocation(roomId, location), this.fixedUserLocation(roomId, targetLocation), direction, headDirection, canStandUp, baseY)); + const fixedLoc = skipLocationFix ? location : this.fixedUserLocation(roomId, location); + const fixedTarget = skipLocationFix ? targetLocation : this.fixedUserLocation(roomId, targetLocation); + + object.processUpdateMessage(new ObjectAvatarUpdateMessage(fixedLoc, fixedTarget, direction, headDirection, canStandUp, baseY)); const roomSession = this._roomSessionManager.getSession(roomId); diff --git a/packages/room/src/RoomMessageHandler.ts b/packages/room/src/RoomMessageHandler.ts index ca8ad2d..fa0bd41 100644 --- a/packages/room/src/RoomMessageHandler.ts +++ b/packages/room/src/RoomMessageHandler.ts @@ -377,7 +377,7 @@ export class RoomMessageHandler if(unitRollData) { - this._roomEngine.updateRoomObjectUserLocation(this._currentRoomId, unitRollData.id, unitRollData.location, unitRollData.targetLocation); + this._roomEngine.updateRoomObjectUserLocation(this._currentRoomId, unitRollData.id, unitRollData.location, unitRollData.targetLocation, false, 0, null, NaN, true); const object = this._roomEngine.getRoomObjectUser(this._currentRoomId, unitRollData.id); diff --git a/packages/room/src/common/floorplan/FloorplanEditor.ts b/packages/room/src/common/floorplan/FloorplanEditor.ts index 05b87c0..d6d2db2 100644 --- a/packages/room/src/common/floorplan/FloorplanEditor.ts +++ b/packages/room/src/common/floorplan/FloorplanEditor.ts @@ -411,26 +411,31 @@ export class FloorplanEditor public getCurrentTilemapString(): string { - this._width = 0; - this._height = 0; + const highestTile = this._tilemap[this._height - 1][this._width - 1]; - for(let y = MAX_NUM_TILE_PER_AXIS - 1; y >= 0; y--) + if(highestTile.height === 'x') { - if(!this._tilemap[y]) continue; + this._width = -1; + this._height = -1; - for(let x = MAX_NUM_TILE_PER_AXIS - 1; x >= 0; x--) + for(let y = MAX_NUM_TILE_PER_AXIS - 1; y >= 0; y--) { - if(!this._tilemap[y][x]) continue; + if(!this._tilemap[y]) continue; - const tile = this._tilemap[y][x]; - - if(tile.height !== 'x') + for(let x = MAX_NUM_TILE_PER_AXIS - 1; x >= 0; x--) { - if((x + 1) > this._width) - this._width = x + 1; + if(!this._tilemap[y][x]) continue; - if((y + 1) > this._height) - this._height = y + 1; + const tile = this._tilemap[y][x]; + + if(tile.height !== 'x') + { + if((x + 1) > this._width) + this._width = x + 1; + + if((y + 1) > this._height) + this._height = y + 1; + } } } } @@ -484,12 +489,6 @@ export class FloorplanEditor if(!tile || tile.isBlocked) continue; tile.height = shouldUnset ? 'x' : this._actionSettings.currentHeight; - - if(!shouldUnset) - { - if((x + 1) > this._width) this._width = x + 1; - if((y + 1) > this._height) this._height = y + 1; - } } }