Attachment Sync: Fehlerbehebung bei Join

This commit is contained in:
hydrant
2020-05-11 15:50:54 +02:00
parent 1242ae575b
commit 04538bddf2
3 changed files with 14 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ class RageEntity implements IEntity {
return this.entity.id; return this.entity.id;
} }
get remoteId(): any { get remoteId(): number {
return this.entity.remoteId; return this.entity.remoteId;
} }
@@ -82,7 +82,7 @@ class RageEntityAttachmentPool implements IEntityAttachmentPool {
for (let i of this.attachmentPool.keys()) { for (let i of this.attachmentPool.keys()) {
let pool = this.attachmentPool[i]; let pool = this.attachmentPool[i];
for (let obj of pool.__attachmentObjects) { for (let obj of pool.__attachmentObjects) {
if (entity == obj) { return pool;} if (entity == obj) { return pool; }
} }
} }
return null; return null;

View File

@@ -42,7 +42,7 @@ interface IBrowser {
interface IEntity { interface IEntity {
id: number; id: number;
remoteId: any; remoteId: number;
type: EntityType; type: EntityType;
getSharedData<T>(key: string): T; getSharedData<T>(key: string): T;
} }

View File

@@ -242,6 +242,11 @@ export default function attachmentManager(game: IGame) {
function InitAttachmentsOnJoin() { function InitAttachmentsOnJoin() {
game.players.forEach(_player => { game.players.forEach(_player => {
let player = mp.players.at(_player.remoteId); let player = mp.players.at(_player.remoteId);
if (!player) {
return;
}
let e = game.attachments.get(_player); let e = game.attachments.get(_player);
if (e == null) { if (e == null) {
let __attachments = []; let __attachments = [];
@@ -259,6 +264,11 @@ export default function attachmentManager(game: IGame) {
game.vehicles.forEach(_veh => { game.vehicles.forEach(_veh => {
let vehicle = mp.vehicles.at(_veh.remoteId); let vehicle = mp.vehicles.at(_veh.remoteId);
if (!vehicle) {
return;
}
let e = game.attachments.get(_veh); let e = game.attachments.get(_veh);
if (e == null) { if (e == null) {
let __attachments = []; let __attachments = [];