quake2ts 0.0.418 → 0.0.420

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14607,13 +14607,111 @@ var GameSession = class {
14607
14607
  }
14608
14608
  }
14609
14609
  loadSavedGame(saveData) {
14610
+ if (this.host) {
14611
+ this.shutdown();
14612
+ }
14613
+ const mapName = saveData.map;
14614
+ const skill = saveData.difficulty;
14615
+ const gameOptions = {
14616
+ gravity: { x: 0, y: 0, z: -800 },
14617
+ skill,
14618
+ deathmatch: false,
14619
+ coop: false
14620
+ };
14621
+ const gameEngineAdapter = {
14622
+ trace: (start, end) => {
14623
+ return this.engine.trace(start, end);
14624
+ },
14625
+ centerprintf: (ent, msg) => {
14626
+ if (this.client) {
14627
+ this.client.ParseCenterPrint(msg);
14628
+ }
14629
+ },
14630
+ configstring: (idx, val) => {
14631
+ if (this.client) {
14632
+ this.client.ParseConfigString(idx, val);
14633
+ }
14634
+ },
14635
+ multicast: () => {
14636
+ },
14637
+ unicast: () => {
14638
+ },
14639
+ serverCommand: () => {
14640
+ }
14641
+ };
14642
+ const gameImports = {
14643
+ trace: (start, mins, maxs, end, passent, contentmask) => {
14644
+ const tr = this.engine.trace(start, end, mins || void 0, maxs || void 0);
14645
+ let plane = null;
14646
+ if (tr.planeNormal) {
14647
+ plane = {
14648
+ normal: tr.planeNormal,
14649
+ dist: 0,
14650
+ type: 0,
14651
+ signbits: 0
14652
+ };
14653
+ }
14654
+ return {
14655
+ allsolid: tr.allsolid,
14656
+ startsolid: tr.startsolid,
14657
+ fraction: tr.fraction,
14658
+ endpos: tr.endpos,
14659
+ plane,
14660
+ surfaceFlags: tr.surfaceFlags ?? 0,
14661
+ contents: tr.contents ?? 0,
14662
+ ent: null
14663
+ };
14664
+ },
14665
+ pointcontents: (p) => {
14666
+ const t = this.engine.trace(p, p, void 0, void 0);
14667
+ return t.contents || 0;
14668
+ },
14669
+ multicast: () => {
14670
+ },
14671
+ unicast: () => {
14672
+ },
14673
+ configstring: (idx, val) => {
14674
+ if (this.client) {
14675
+ this.client.ParseConfigString(idx, val);
14676
+ }
14677
+ },
14678
+ serverCommand: (cmd) => {
14679
+ }
14680
+ };
14681
+ this.game = (0, import_game5.createGame)(gameImports, gameEngineAdapter, gameOptions);
14682
+ const clientProxy = {
14683
+ init: (initial) => this.client?.init(initial),
14684
+ render: (sample) => this.client?.render(sample),
14685
+ shutdown: () => this.client?.shutdown(),
14686
+ get camera() {
14687
+ return this.client?.camera;
14688
+ }
14689
+ };
14690
+ this.host = new EngineHost(this.game, clientProxy);
14691
+ const clientImports = {
14692
+ engine: this.engine,
14693
+ host: this.host
14694
+ };
14695
+ this.client = createClient(clientImports);
14696
+ if (this.engine.cmd) {
14697
+ this.engine.cmd.executeText(`map ${mapName}`);
14698
+ } else if (this.host.commands) {
14699
+ this.host.commands.execute(`map ${mapName}`);
14700
+ }
14701
+ if (this.game) {
14702
+ this.game.loadSave(saveData);
14703
+ }
14704
+ this.host.start();
14610
14705
  }
14611
14706
  shutdown() {
14612
14707
  if (this.host) {
14613
14708
  this.host.stop();
14614
14709
  this.host = null;
14615
14710
  }
14616
- this.client = null;
14711
+ if (this.client) {
14712
+ this.client.shutdown();
14713
+ this.client = null;
14714
+ }
14617
14715
  this.game = null;
14618
14716
  }
14619
14717
  getClient() {
@@ -15146,23 +15244,18 @@ function createClient(imports) {
15146
15244
  }, renderEntities);
15147
15245
  }
15148
15246
  if (imports.engine.renderer && lastRendered && lastRendered.client) {
15149
- const stats = imports.engine.renderer.stats ? {
15150
- ...imports.engine.renderer.stats,
15151
- batches: 0,
15152
- facesDrawn: 0,
15153
- drawCalls: 0,
15154
- skyDrawn: false,
15155
- viewModelDrawn: false,
15156
- fps: 0,
15157
- vertexCount: 0
15158
- } : {
15159
- batches: 0,
15160
- facesDrawn: 0,
15161
- drawCalls: 0,
15247
+ const perfReport = imports.engine.renderer.getPerformanceReport();
15248
+ const stats = {
15249
+ batches: perfReport.textureBinds,
15250
+ facesDrawn: perfReport.triangles,
15251
+ // approximate
15252
+ drawCalls: perfReport.drawCalls,
15162
15253
  skyDrawn: false,
15254
+ // Not exposed in report
15163
15255
  viewModelDrawn: false,
15256
+ // Not exposed in report
15164
15257
  fps: 0,
15165
- vertexCount: 0
15258
+ vertexCount: perfReport.vertices
15166
15259
  };
15167
15260
  const timeMs = sample.latest?.timeMs ?? 0;
15168
15261
  this.DrawHUD(stats, timeMs);