cr fixes #1 wip
This commit is contained in:
parent
3c74b2b554
commit
3a5aa3c3c5
@ -46,7 +46,7 @@ export class GameRoom {
|
|||||||
// Users, sorted by ID
|
// Users, sorted by ID
|
||||||
private readonly users = new Map<number, User>();
|
private readonly users = new Map<number, User>();
|
||||||
private readonly usersByUuid = new Map<string, User>();
|
private readonly usersByUuid = new Map<string, User>();
|
||||||
private readonly groups = new Set<Group>();
|
private readonly groups: Map<number, Group> = new Map<number, Group>();
|
||||||
private readonly admins = new Set<Admin>();
|
private readonly admins = new Set<Admin>();
|
||||||
|
|
||||||
private itemsState = new Map<number, unknown>();
|
private itemsState = new Map<number, unknown>();
|
||||||
@ -250,7 +250,7 @@ export class GameRoom {
|
|||||||
this.disconnectCallback,
|
this.disconnectCallback,
|
||||||
this.positionNotifier
|
this.positionNotifier
|
||||||
);
|
);
|
||||||
this.groups.add(group);
|
this.groups.set(group.getId(), group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -334,7 +334,7 @@ export class GameRoom {
|
|||||||
this.disconnectCallback,
|
this.disconnectCallback,
|
||||||
this.positionNotifier
|
this.positionNotifier
|
||||||
);
|
);
|
||||||
this.groups.add(newGroup);
|
this.groups.set(newGroup.getId(), newGroup);
|
||||||
} else {
|
} else {
|
||||||
this.leaveGroup(user);
|
this.leaveGroup(user);
|
||||||
}
|
}
|
||||||
@ -381,10 +381,10 @@ export class GameRoom {
|
|||||||
group.leave(user);
|
group.leave(user);
|
||||||
if (group.isEmpty()) {
|
if (group.isEmpty()) {
|
||||||
group.destroy();
|
group.destroy();
|
||||||
if (!this.groups.has(group)) {
|
if (!this.groups.has(group.getId())) {
|
||||||
throw new Error(`Could not find group ${group.getId()} referenced by user ${user.id} in World.`);
|
throw new Error(`Could not find group ${group.getId()} referenced by user ${user.id} in World.`);
|
||||||
}
|
}
|
||||||
this.groups.delete(group);
|
this.groups.delete(group.getId());
|
||||||
//todo: is the group garbage collected?
|
//todo: is the group garbage collected?
|
||||||
} else {
|
} else {
|
||||||
group.updatePosition();
|
group.updatePosition();
|
||||||
@ -664,4 +664,8 @@ export class GameRoom {
|
|||||||
const variablesManager = await this.getVariableManager();
|
const variablesManager = await this.getVariableManager();
|
||||||
return variablesManager.getVariablesForTags(tags);
|
return variablesManager.getVariablesForTags(tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getGroupById(id: number): Group | undefined {
|
||||||
|
return this.groups.get(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ import {
|
|||||||
GroupUsersUpdateMessage,
|
GroupUsersUpdateMessage,
|
||||||
LockGroupMessage,
|
LockGroupMessage,
|
||||||
LockGroupPromptMessage,
|
LockGroupPromptMessage,
|
||||||
|
RoomMessage,
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
import { User, UserSocket } from "../Model/User";
|
import { User, UserSocket } from "../Model/User";
|
||||||
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
||||||
@ -287,7 +288,7 @@ export class SocketManager {
|
|||||||
(emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) =>
|
(emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) =>
|
||||||
this.onEmote(emoteEventMessage, listener),
|
this.onEmote(emoteEventMessage, listener),
|
||||||
(lockGroupMessage: LockGroupMessage, listener: ZoneSocket) =>
|
(lockGroupMessage: LockGroupMessage, listener: ZoneSocket) =>
|
||||||
this.onLockGroup(lockGroupMessage, listener),
|
this.onLockGroup(lockGroupMessage, listener, roomPromise),
|
||||||
(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket) =>
|
(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket) =>
|
||||||
this.onPlayerDetailsUpdated(playerDetailsUpdatedMessage, listener)
|
this.onPlayerDetailsUpdated(playerDetailsUpdatedMessage, listener)
|
||||||
)
|
)
|
||||||
@ -391,10 +392,19 @@ export class SocketManager {
|
|||||||
emitZoneMessage(subMessage, client);
|
emitZoneMessage(subMessage, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onLockGroup(lockGroupMessage: LockGroupMessage, client: ZoneSocket) {
|
private async onLockGroup(
|
||||||
const subMessage = new SubToPusherMessage();
|
lockGroupMessage: LockGroupMessage,
|
||||||
subMessage.setLockgroupmessage(lockGroupMessage);
|
client: ZoneSocket,
|
||||||
emitZoneMessage(subMessage, client);
|
roomPromise: PromiseLike<GameRoom> | undefined
|
||||||
|
) {
|
||||||
|
if (!roomPromise) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const group = (await roomPromise).getGroupById(lockGroupMessage.getGroupid());
|
||||||
|
if (!group) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.emitCreateUpdateGroupEvent(client, null, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, client: ZoneSocket) {
|
private onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, client: ZoneSocket) {
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
[ZoneTransfer]
|
|
||||||
ZoneId=3
|
|
||||||
HostUrl=about:internet
|
|
@ -2010,6 +2010,7 @@ ${escapedMessage}
|
|||||||
}
|
}
|
||||||
|
|
||||||
private doShareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface) {
|
private doShareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface) {
|
||||||
|
console.log(groupPositionMessage);
|
||||||
//delete previous group
|
//delete previous group
|
||||||
this.doDeleteGroup(groupPositionMessage.groupId);
|
this.doDeleteGroup(groupPositionMessage.groupId);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user