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.
@@ -14575,13 +14575,111 @@ var GameSession = class {
14575
14575
  }
14576
14576
  }
14577
14577
  loadSavedGame(saveData) {
14578
+ if (this.host) {
14579
+ this.shutdown();
14580
+ }
14581
+ const mapName = saveData.map;
14582
+ const skill = saveData.difficulty;
14583
+ const gameOptions = {
14584
+ gravity: { x: 0, y: 0, z: -800 },
14585
+ skill,
14586
+ deathmatch: false,
14587
+ coop: false
14588
+ };
14589
+ const gameEngineAdapter = {
14590
+ trace: (start, end) => {
14591
+ return this.engine.trace(start, end);
14592
+ },
14593
+ centerprintf: (ent, msg) => {
14594
+ if (this.client) {
14595
+ this.client.ParseCenterPrint(msg);
14596
+ }
14597
+ },
14598
+ configstring: (idx, val) => {
14599
+ if (this.client) {
14600
+ this.client.ParseConfigString(idx, val);
14601
+ }
14602
+ },
14603
+ multicast: () => {
14604
+ },
14605
+ unicast: () => {
14606
+ },
14607
+ serverCommand: () => {
14608
+ }
14609
+ };
14610
+ const gameImports = {
14611
+ trace: (start, mins, maxs, end, passent, contentmask) => {
14612
+ const tr = this.engine.trace(start, end, mins || void 0, maxs || void 0);
14613
+ let plane = null;
14614
+ if (tr.planeNormal) {
14615
+ plane = {
14616
+ normal: tr.planeNormal,
14617
+ dist: 0,
14618
+ type: 0,
14619
+ signbits: 0
14620
+ };
14621
+ }
14622
+ return {
14623
+ allsolid: tr.allsolid,
14624
+ startsolid: tr.startsolid,
14625
+ fraction: tr.fraction,
14626
+ endpos: tr.endpos,
14627
+ plane,
14628
+ surfaceFlags: tr.surfaceFlags ?? 0,
14629
+ contents: tr.contents ?? 0,
14630
+ ent: null
14631
+ };
14632
+ },
14633
+ pointcontents: (p) => {
14634
+ const t = this.engine.trace(p, p, void 0, void 0);
14635
+ return t.contents || 0;
14636
+ },
14637
+ multicast: () => {
14638
+ },
14639
+ unicast: () => {
14640
+ },
14641
+ configstring: (idx, val) => {
14642
+ if (this.client) {
14643
+ this.client.ParseConfigString(idx, val);
14644
+ }
14645
+ },
14646
+ serverCommand: (cmd) => {
14647
+ }
14648
+ };
14649
+ this.game = createGame(gameImports, gameEngineAdapter, gameOptions);
14650
+ const clientProxy = {
14651
+ init: (initial) => this.client?.init(initial),
14652
+ render: (sample) => this.client?.render(sample),
14653
+ shutdown: () => this.client?.shutdown(),
14654
+ get camera() {
14655
+ return this.client?.camera;
14656
+ }
14657
+ };
14658
+ this.host = new EngineHost(this.game, clientProxy);
14659
+ const clientImports = {
14660
+ engine: this.engine,
14661
+ host: this.host
14662
+ };
14663
+ this.client = createClient(clientImports);
14664
+ if (this.engine.cmd) {
14665
+ this.engine.cmd.executeText(`map ${mapName}`);
14666
+ } else if (this.host.commands) {
14667
+ this.host.commands.execute(`map ${mapName}`);
14668
+ }
14669
+ if (this.game) {
14670
+ this.game.loadSave(saveData);
14671
+ }
14672
+ this.host.start();
14578
14673
  }
14579
14674
  shutdown() {
14580
14675
  if (this.host) {
14581
14676
  this.host.stop();
14582
14677
  this.host = null;
14583
14678
  }
14584
- this.client = null;
14679
+ if (this.client) {
14680
+ this.client.shutdown();
14681
+ this.client = null;
14682
+ }
14585
14683
  this.game = null;
14586
14684
  }
14587
14685
  getClient() {
@@ -15114,23 +15212,18 @@ function createClient(imports) {
15114
15212
  }, renderEntities);
15115
15213
  }
15116
15214
  if (imports.engine.renderer && lastRendered && lastRendered.client) {
15117
- const stats = imports.engine.renderer.stats ? {
15118
- ...imports.engine.renderer.stats,
15119
- batches: 0,
15120
- facesDrawn: 0,
15121
- drawCalls: 0,
15122
- skyDrawn: false,
15123
- viewModelDrawn: false,
15124
- fps: 0,
15125
- vertexCount: 0
15126
- } : {
15127
- batches: 0,
15128
- facesDrawn: 0,
15129
- drawCalls: 0,
15215
+ const perfReport = imports.engine.renderer.getPerformanceReport();
15216
+ const stats = {
15217
+ batches: perfReport.textureBinds,
15218
+ facesDrawn: perfReport.triangles,
15219
+ // approximate
15220
+ drawCalls: perfReport.drawCalls,
15130
15221
  skyDrawn: false,
15222
+ // Not exposed in report
15131
15223
  viewModelDrawn: false,
15224
+ // Not exposed in report
15132
15225
  fps: 0,
15133
- vertexCount: 0
15226
+ vertexCount: perfReport.vertices
15134
15227
  };
15135
15228
  const timeMs = sample.latest?.timeMs ?? 0;
15136
15229
  this.DrawHUD(stats, timeMs);