mirror of
https://github.com/demostf/demo.js
synced 2026-06-03 16:44:12 +02:00
use map for outerMap
This commit is contained in:
parent
6eebb18251
commit
61f99b87cf
3 changed files with 7 additions and 6 deletions
|
|
@ -35,7 +35,7 @@ export class Match {
|
|||
public sendTables: Map<string, SendTable> = new Map();
|
||||
public baseLineCache: Map<ServerClass, PacketEntity> = new Map();
|
||||
public weaponMap: Map<EntityId, Weapon> = new Map();
|
||||
public outerMap: {[outer: number]: number};
|
||||
public outerMap: Map<number, EntityId> = new Map();
|
||||
public teams: Map<TeamNumber, Team> = new Map();
|
||||
public teamEntityMap: Map<EntityId, Team>;
|
||||
public version: number;
|
||||
|
|
@ -61,7 +61,6 @@ export class Match {
|
|||
boundaryMin: {x: 0, y: 0, z: 0},
|
||||
boundaryMax: {x: 0, y: 0, z: 0},
|
||||
};
|
||||
this.outerMap = {};
|
||||
this.teamEntityMap = new Map();
|
||||
this.version = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {PlayerCondition} from './PlayerCondition';
|
|||
import {UserInfo} from './UserInfo';
|
||||
import {Vector} from './Vector';
|
||||
import {Weapon} from './Weapon';
|
||||
import {EntityId} from './PacketEntity';
|
||||
|
||||
export enum LifeState {
|
||||
ALIVE = 0,
|
||||
|
|
@ -32,7 +33,8 @@ export class Player {
|
|||
|
||||
get weapons(): Weapon[] {
|
||||
return this.weaponIds
|
||||
.map((id) => this.match.weaponMap.get(this.match.outerMap[id]) as Weapon)
|
||||
.filter((weapon: Weapon | undefined) => (typeof weapon !== 'undefined'));
|
||||
.map(id => this.match.outerMap.get(id) as EntityId)
|
||||
.filter(entityId => entityId > 0)
|
||||
.map(entityId => this.match.weaponMap.get(entityId) as Weapon);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ function saveEntity(packetEntity: PacketEntity, match: Match) {
|
|||
function handleEntity(entity: PacketEntity, match: Match) {
|
||||
for (const prop of entity.props) {
|
||||
if (prop.definition.ownerTableName === 'DT_AttributeContainer' && prop.definition.name === 'm_hOuter') {
|
||||
if (!match.outerMap[prop.value as number]) {
|
||||
match.outerMap[prop.value as number] = entity.entityIndex;
|
||||
if (!match.outerMap.has(prop.value as number)) {
|
||||
match.outerMap.set(prop.value as number, entity.entityIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue