@quake2ts/engine 0.0.1 → 0.0.740

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.
@@ -1,232 +1,8 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
19
2
 
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- ATTN_IDLE: () => ATTN_IDLE,
24
- ATTN_LOOP_NONE: () => ATTN_LOOP_NONE,
25
- ATTN_NONE: () => ATTN_NONE,
26
- ATTN_NORM: () => ATTN_NORM,
27
- ATTN_STATIC: () => ATTN_STATIC,
28
- AssetDependencyError: () => AssetDependencyError,
29
- AssetDependencyTracker: () => AssetDependencyTracker,
30
- AssetManager: () => AssetManager,
31
- AssetPreviewGenerator: () => AssetPreviewGenerator,
32
- AudioApi: () => AudioApi,
33
- AudioContextController: () => AudioContextController,
34
- AudioOcclusion: () => AudioOcclusion,
35
- AudioRegistry: () => AudioRegistry,
36
- AudioRegistryError: () => AudioRegistryError,
37
- AudioSystem: () => AudioSystem,
38
- BSP_SURFACE_FRAGMENT_SOURCE: () => BSP_SURFACE_FRAGMENT_SOURCE,
39
- BSP_SURFACE_VERTEX_SOURCE: () => BSP_SURFACE_VERTEX_SOURCE,
40
- BSP_VERTEX_LAYOUT: () => BSP_VERTEX_LAYOUT,
41
- BspLoader: () => BspLoader,
42
- BspParseError: () => BspParseError,
43
- BspSurfacePipeline: () => BspSurfacePipeline,
44
- Camera: () => Camera,
45
- ClientConnection: () => ClientConnection,
46
- Command: () => Command,
47
- CommandRegistry: () => CommandRegistry,
48
- ConfigStringRegistry: () => ConfigStringRegistry,
49
- ConnectionState: () => ConnectionState,
50
- Cvar: () => Cvar,
51
- CvarRegistry: () => CvarRegistry,
52
- DemoAnalyzer: () => DemoAnalyzer,
53
- DemoCameraMode: () => DemoCameraMode,
54
- DemoClipper: () => DemoClipper,
55
- DemoEventType: () => DemoEventType,
56
- DemoPlaybackController: () => DemoPlaybackController,
57
- DemoReader: () => DemoReader,
58
- DemoRecorder: () => DemoRecorder,
59
- DemoValidator: () => DemoValidator,
60
- DynamicLightManager: () => DynamicLightManager,
61
- EngineHost: () => EngineHost,
62
- EngineRuntime: () => EngineRuntime,
63
- FileType: () => FileType,
64
- FixedTimestepLoop: () => FixedTimestepLoop,
65
- Framebuffer: () => Framebuffer,
66
- IndexBuffer: () => IndexBuffer,
67
- LruCache: () => LruCache,
68
- MAX_SOUND_CHANNELS: () => MAX_SOUND_CHANNELS,
69
- MD2_FRAGMENT_SHADER: () => MD2_FRAGMENT_SHADER,
70
- MD2_VERTEX_SHADER: () => MD2_VERTEX_SHADER,
71
- MD3_FRAGMENT_SHADER: () => MD3_FRAGMENT_SHADER,
72
- MD3_VERTEX_SHADER: () => MD3_VERTEX_SHADER,
73
- MapAnalyzer: () => MapAnalyzer,
74
- Md2Loader: () => Md2Loader,
75
- Md2MeshBuffers: () => Md2MeshBuffers,
76
- Md2ParseError: () => Md2ParseError,
77
- Md2Pipeline: () => Md2Pipeline,
78
- Md3Loader: () => Md3Loader,
79
- Md3ModelMesh: () => Md3ModelMesh,
80
- Md3ParseError: () => Md3ParseError,
81
- Md3Pipeline: () => Md3Pipeline,
82
- Md3SurfaceMesh: () => Md3SurfaceMesh,
83
- MessageWriter: () => MessageWriter,
84
- MusicSystem: () => MusicSystem,
85
- NetworkMessageParser: () => NetworkMessageParser,
86
- PARTICLE_FRAGMENT_SHADER: () => PARTICLE_FRAGMENT_SHADER,
87
- PARTICLE_VERTEX_SHADER: () => PARTICLE_VERTEX_SHADER,
88
- PROTOCOL_VERSION_RERELEASE: () => PROTOCOL_VERSION_RERELEASE,
89
- PakArchive: () => PakArchive,
90
- PakIndexStore: () => PakIndexStore,
91
- PakIngestionError: () => PakIngestionError,
92
- PakParseError: () => PakParseError,
93
- PakValidationError: () => PakValidationError,
94
- PakValidator: () => PakValidator,
95
- PakWriter: () => PakWriter,
96
- ParticleRenderer: () => ParticleRenderer,
97
- ParticleSystem: () => ParticleSystem,
98
- PlaybackState: () => PlaybackState,
99
- RERELEASE_KNOWN_PAKS: () => RERELEASE_KNOWN_PAKS,
100
- ResourceLoadTracker: () => ResourceLoadTracker,
101
- ResourceType: () => ResourceType,
102
- SKYBOX_FRAGMENT_SHADER: () => SKYBOX_FRAGMENT_SHADER,
103
- SKYBOX_VERTEX_SHADER: () => SKYBOX_VERTEX_SHADER,
104
- SOUND_FULLVOLUME: () => SOUND_FULLVOLUME,
105
- SOUND_LOOP_ATTENUATE: () => SOUND_LOOP_ATTENUATE,
106
- ShaderProgram: () => ShaderProgram,
107
- SkyboxPipeline: () => SkyboxPipeline,
108
- SoundChannel: () => SoundChannel,
109
- SoundPrecache: () => SoundPrecache,
110
- SoundRegistry: () => SoundRegistry,
111
- SpriteLoader: () => SpriteLoader,
112
- SpriteParseError: () => SpriteParseError,
113
- SpriteRenderer: () => SpriteRenderer,
114
- StreamingPakArchive: () => StreamingPakArchive,
115
- Texture2D: () => Texture2D,
116
- TextureCache: () => TextureCache,
117
- TextureCubeMap: () => TextureCubeMap,
118
- TgaParseError: () => TgaParseError,
119
- U_ALPHA: () => U_ALPHA2,
120
- U_ANGLE1: () => U_ANGLE12,
121
- U_ANGLE2: () => U_ANGLE22,
122
- U_ANGLE3: () => U_ANGLE32,
123
- U_EFFECTS16: () => U_EFFECTS162,
124
- U_EFFECTS8: () => U_EFFECTS82,
125
- U_EVENT: () => U_EVENT2,
126
- U_FRAME16: () => U_FRAME162,
127
- U_FRAME8: () => U_FRAME82,
128
- U_INSTANCE_BITS: () => U_INSTANCE_BITS2,
129
- U_LOOP_ATTENUATION_HIGH: () => U_LOOP_ATTENUATION_HIGH2,
130
- U_LOOP_VOLUME: () => U_LOOP_VOLUME2,
131
- U_MODEL: () => U_MODEL5,
132
- U_MODEL2: () => U_MODEL22,
133
- U_MODEL3: () => U_MODEL32,
134
- U_MODEL4: () => U_MODEL42,
135
- U_OLDORIGIN: () => U_OLDORIGIN2,
136
- U_OLD_FRAME_HIGH: () => U_OLD_FRAME_HIGH2,
137
- U_ORIGIN1: () => U_ORIGIN12,
138
- U_ORIGIN2: () => U_ORIGIN22,
139
- U_ORIGIN3: () => U_ORIGIN32,
140
- U_OWNER_HIGH: () => U_OWNER_HIGH2,
141
- U_REMOVE: () => U_REMOVE2,
142
- U_RENDERFX16: () => U_RENDERFX162,
143
- U_RENDERFX8: () => U_RENDERFX82,
144
- U_SCALE: () => U_SCALE2,
145
- U_SKIN16: () => U_SKIN162,
146
- U_SKIN8: () => U_SKIN82,
147
- U_SOLID: () => U_SOLID2,
148
- U_SOUND: () => U_SOUND2,
149
- VertexArray: () => VertexArray,
150
- VertexBuffer: () => VertexBuffer,
151
- VirtualFileSystem: () => VirtualFileSystem,
152
- advanceAnimation: () => advanceAnimation,
153
- applyEntityDelta: () => applyEntityDelta,
154
- applySurfaceState: () => applySurfaceState,
155
- attenuationToDistanceMultiplier: () => attenuationToDistanceMultiplier,
156
- boxIntersectsFrustum: () => boxIntersectsFrustum,
157
- buildBspGeometry: () => buildBspGeometry,
158
- buildMd2Geometry: () => buildMd2Geometry,
159
- buildMd2VertexData: () => buildMd2VertexData,
160
- buildMd3SurfaceGeometry: () => buildMd3SurfaceGeometry,
161
- buildMd3VertexData: () => buildMd3VertexData,
162
- calculateMaxAudibleDistance: () => calculateMaxAudibleDistance,
163
- calculatePakChecksum: () => calculatePakChecksum,
164
- captureRenderTarget: () => captureRenderTarget,
165
- computeFrameBlend: () => computeFrameBlend,
166
- computeSkyScroll: () => computeSkyScroll,
167
- createAnimationState: () => createAnimationState,
168
- createAudioGraph: () => createAudioGraph,
169
- createBspSurfaces: () => createBspSurfaces,
170
- createEmptyEntityState: () => createEmptyEntityState,
171
- createEmptyProtocolPlayerState: () => createEmptyProtocolPlayerState,
172
- createEngine: () => createEngine,
173
- createEngineRuntime: () => createEngineRuntime,
174
- createFaceLightmap: () => createFaceLightmap,
175
- createHeadlessRenderTarget: () => createHeadlessRenderTarget,
176
- createInitialChannels: () => createInitialChannels,
177
- createOcclusionResolver: () => createOcclusionResolver,
178
- createProgramFromSources: () => createProgramFromSources,
179
- createWebGLContext: () => createWebGLContext,
180
- createWebGPUContext: () => createWebGPUContext,
181
- decodeOgg: () => decodeOgg,
182
- deriveSurfaceRenderState: () => deriveSurfaceRenderState,
183
- detectFileType: () => detectFileType,
184
- extractFrustumPlanes: () => extractFrustumPlanes,
185
- filesToPakSources: () => filesToPakSources,
186
- findLeafForPoint: () => findLeafForPoint,
187
- gatherVisibleFaces: () => gatherVisibleFaces,
188
- groupMd2Animations: () => groupMd2Animations,
189
- ingestPakFiles: () => ingestPakFiles,
190
- ingestPaks: () => ingestPaks,
191
- interpolateMd3Tag: () => interpolateMd3Tag,
192
- interpolateVec3: () => interpolateVec3,
193
- isBinaryFile: () => isBinaryFile,
194
- isTextFile: () => isTextFile,
195
- parseBsp: () => parseBsp,
196
- parseEntLump: () => parseEntLump,
197
- parseMd2: () => parseMd2,
198
- parseMd3: () => parseMd3,
199
- parsePcx: () => parsePcx,
200
- parseSprite: () => parseSprite,
201
- parseTga: () => parseTga,
202
- parseWal: () => parseWal,
203
- parseWalTexture: () => parseWalTexture,
204
- parseWav: () => parseWav,
205
- pcxToRgba: () => pcxToRgba,
206
- pickChannel: () => pickChannel,
207
- preparePcxTexture: () => preparePcxTexture,
208
- queryCapabilities: () => queryCapabilities,
209
- removeViewTranslation: () => removeViewTranslation,
210
- resolveLightStyles: () => resolveLightStyles,
211
- serializeEntLump: () => serializeEntLump,
212
- spawnBfgExplosion: () => spawnBfgExplosion,
213
- spawnBlasterImpact: () => spawnBlasterImpact,
214
- spawnBlood: () => spawnBlood,
215
- spawnBulletImpact: () => spawnBulletImpact,
216
- spawnExplosion: () => spawnExplosion,
217
- spawnMuzzleFlash: () => spawnMuzzleFlash,
218
- spawnRailTrail: () => spawnRailTrail,
219
- spawnSparks: () => spawnSparks,
220
- spawnSplash: () => spawnSplash,
221
- spawnSteam: () => spawnSteam,
222
- spawnTeleportFlash: () => spawnTeleportFlash,
223
- spawnTrail: () => spawnTrail,
224
- validateEntity: () => validateEntity,
225
- walToRgba: () => walToRgba,
226
- wireDropTarget: () => wireDropTarget,
227
- wireFileInput: () => wireFileInput
228
- });
229
- module.exports = __toCommonJS(index_exports);
3
+ var shared = require('@quake2ts/shared');
4
+ var oggVorbis = require('@wasm-audio-decoders/ogg-vorbis');
5
+ var glMatrix = require('gl-matrix');
230
6
 
231
7
  // src/loop.ts
232
8
  var DEFAULT_FIXED_DELTA_MS = 25;
@@ -410,1532 +186,12 @@ var CommandRegistry = class {
410
186
  return [...this.commands.values()].sort((a, b) => a.name.localeCompare(b.name));
411
187
  }
412
188
  };
413
-
414
- // ../shared/dist/esm/index.js
415
- var __defProp2 = Object.defineProperty;
416
- var __export2 = (target, all) => {
417
- for (var name in all)
418
- __defProp2(target, name, { get: all[name], enumerable: true });
419
- };
420
- var ZERO_VEC3 = { x: 0, y: 0, z: 0 };
421
- var DEG_TO_RAD = Math.PI / 180;
422
- function subtractVec3(a, b) {
423
- return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
424
- }
425
- function scaleVec3(a, scalar) {
426
- return { x: a.x * scalar, y: a.y * scalar, z: a.z * scalar };
427
- }
428
- function dotVec3(a, b) {
429
- return a.x * b.x + a.y * b.y + a.z * b.z;
430
- }
431
- function lengthSquaredVec3(a) {
432
- return dotVec3(a, a);
433
- }
434
- function lengthVec3(a) {
435
- return Math.sqrt(lengthSquaredVec3(a));
436
- }
437
- function normalizeVec3(a) {
438
- const len = lengthVec3(a);
439
- return len === 0 ? a : scaleVec3(a, 1 / len);
440
- }
441
- var DEG2RAD_FACTOR = Math.PI / 180;
442
- var RAD2DEG_FACTOR = 180 / Math.PI;
443
- var DEG2RAD = DEG2RAD_FACTOR;
444
- var RAD2DEG = RAD2DEG_FACTOR;
445
- var ANORMS = [
446
- [-0.525731, 0, 0.850651],
447
- [-0.442863, 0.238856, 0.864188],
448
- [-0.295242, 0, 0.955423],
449
- [-0.309017, 0.5, 0.809017],
450
- [-0.16246, 0.262866, 0.951056],
451
- [0, 0, 1],
452
- [0, 0.850651, 0.525731],
453
- [-0.147621, 0.716567, 0.681718],
454
- [0.147621, 0.716567, 0.681718],
455
- [0, 0.525731, 0.850651],
456
- [0.309017, 0.5, 0.809017],
457
- [0.525731, 0, 0.850651],
458
- [0.295242, 0, 0.955423],
459
- [0.442863, 0.238856, 0.864188],
460
- [0.16246, 0.262866, 0.951056],
461
- [-0.681718, 0.147621, 0.716567],
462
- [-0.809017, 0.309017, 0.5],
463
- [-0.587785, 0.425325, 0.688191],
464
- [-0.850651, 0.525731, 0],
465
- [-0.864188, 0.442863, 0.238856],
466
- [-0.716567, 0.681718, 0.147621],
467
- [-0.688191, 0.587785, 0.425325],
468
- [-0.5, 0.809017, 0.309017],
469
- [-0.238856, 0.864188, 0.442863],
470
- [-0.425325, 0.688191, 0.587785],
471
- [-0.716567, 0.681718, -0.147621],
472
- [-0.5, 0.809017, -0.309017],
473
- [-0.525731, 0.850651, 0],
474
- [0, 0.850651, -0.525731],
475
- [-0.238856, 0.864188, -0.442863],
476
- [0, 0.955423, -0.295242],
477
- [-0.262866, 0.951056, -0.16246],
478
- [0, 1, 0],
479
- [0, 0.955423, 0.295242],
480
- [-0.262866, 0.951056, 0.16246],
481
- [0.238856, 0.864188, 0.442863],
482
- [0.262866, 0.951056, 0.16246],
483
- [0.5, 0.809017, 0.309017],
484
- [0.238856, 0.864188, -0.442863],
485
- [0.262866, 0.951056, -0.16246],
486
- [0.5, 0.809017, -0.309017],
487
- [0.850651, 0.525731, 0],
488
- [0.716567, 0.681718, 0.147621],
489
- [0.716567, 0.681718, -0.147621],
490
- [0.525731, 0.850651, 0],
491
- [0.425325, 0.688191, 0.587785],
492
- [0.864188, 0.442863, 0.238856],
493
- [0.688191, 0.587785, 0.425325],
494
- [0.809017, 0.309017, 0.5],
495
- [0.681718, 0.147621, 0.716567],
496
- [0.587785, 0.425325, 0.688191],
497
- [0.955423, 0.295242, 0],
498
- [1, 0, 0],
499
- [0.951056, 0.16246, 0.262866],
500
- [0.850651, -0.525731, 0],
501
- [0.955423, -0.295242, 0],
502
- [0.864188, -0.442863, 0.238856],
503
- [0.951056, -0.16246, 0.262866],
504
- [0.809017, -0.309017, 0.5],
505
- [0.681718, -0.147621, 0.716567],
506
- [0.850651, 0, 0.525731],
507
- [0.864188, 0.442863, -0.238856],
508
- [0.809017, 0.309017, -0.5],
509
- [0.951056, 0.16246, -0.262866],
510
- [0.525731, 0, -0.850651],
511
- [0.681718, 0.147621, -0.716567],
512
- [0.681718, -0.147621, -0.716567],
513
- [0.850651, 0, -0.525731],
514
- [0.809017, -0.309017, -0.5],
515
- [0.864188, -0.442863, -0.238856],
516
- [0.951056, -0.16246, -0.262866],
517
- [0.147621, 0.716567, -0.681718],
518
- [0.309017, 0.5, -0.809017],
519
- [0.425325, 0.688191, -0.587785],
520
- [0.442863, 0.238856, -0.864188],
521
- [0.587785, 0.425325, -0.688191],
522
- [0.688191, 0.587785, -0.425325],
523
- [-0.147621, 0.716567, -0.681718],
524
- [-0.309017, 0.5, -0.809017],
525
- [0, 0.525731, -0.850651],
526
- [-0.525731, 0, -0.850651],
527
- [-0.442863, 0.238856, -0.864188],
528
- [-0.295242, 0, -0.955423],
529
- [-0.16246, 0.262866, -0.951056],
530
- [0, 0, -1],
531
- [0.295242, 0, -0.955423],
532
- [0.16246, 0.262866, -0.951056],
533
- [-0.442863, -0.238856, -0.864188],
534
- [-0.309017, -0.5, -0.809017],
535
- [-0.16246, -0.262866, -0.951056],
536
- [0, -0.850651, -0.525731],
537
- [-0.147621, -0.716567, -0.681718],
538
- [0.147621, -0.716567, -0.681718],
539
- [0, -0.525731, -0.850651],
540
- [0.309017, -0.5, -0.809017],
541
- [0.442863, -0.238856, -0.864188],
542
- [0.16246, -0.262866, -0.951056],
543
- [0.238856, -0.864188, -0.442863],
544
- [0.5, -0.809017, -0.309017],
545
- [0.425325, -0.688191, -0.587785],
546
- [0.716567, -0.681718, -0.147621],
547
- [0.688191, -0.587785, -0.425325],
548
- [0.587785, -0.425325, -0.688191],
549
- [0, -0.955423, -0.295242],
550
- [0, -1, 0],
551
- [0.262866, -0.951056, -0.16246],
552
- [0, -0.850651, 0.525731],
553
- [0, -0.955423, 0.295242],
554
- [0.238856, -0.864188, 0.442863],
555
- [0.262866, -0.951056, 0.16246],
556
- [0.5, -0.809017, 0.309017],
557
- [0.716567, -0.681718, 0.147621],
558
- [0.525731, -0.850651, 0],
559
- [-0.238856, -0.864188, -0.442863],
560
- [-0.5, -0.809017, -0.309017],
561
- [-0.262866, -0.951056, -0.16246],
562
- [-0.850651, -0.525731, 0],
563
- [-0.716567, -0.681718, -0.147621],
564
- [-0.716567, -0.681718, 0.147621],
565
- [-0.525731, -0.850651, 0],
566
- [-0.5, -0.809017, 0.309017],
567
- [-0.238856, -0.864188, 0.442863],
568
- [-0.262866, -0.951056, 0.16246],
569
- [-0.864188, -0.442863, 0.238856],
570
- [-0.809017, -0.309017, 0.5],
571
- [-0.688191, -0.587785, 0.425325],
572
- [-0.681718, -0.147621, 0.716567],
573
- [-0.442863, -0.238856, 0.864188],
574
- [-0.587785, -0.425325, 0.688191],
575
- [-0.309017, -0.5, 0.809017],
576
- [-0.147621, -0.716567, 0.681718],
577
- [-0.425325, -0.688191, 0.587785],
578
- [-0.16246, -0.262866, 0.951056],
579
- [0.442863, -0.238856, 0.864188],
580
- [0.16246, -0.262866, 0.951056],
581
- [0.309017, -0.5, 0.809017],
582
- [0.147621, -0.716567, 0.681718],
583
- [0, -0.525731, 0.850651],
584
- [0.425325, -0.688191, 0.587785],
585
- [0.587785, -0.425325, 0.688191],
586
- [0.688191, -0.587785, 0.425325],
587
- [-0.955423, 0.295242, 0],
588
- [-0.951056, 0.16246, 0.262866],
589
- [-1, 0, 0],
590
- [-0.850651, 0, 0.525731],
591
- [-0.955423, -0.295242, 0],
592
- [-0.951056, -0.16246, 0.262866],
593
- [-0.864188, 0.442863, -0.238856],
594
- [-0.951056, 0.16246, -0.262866],
595
- [-0.809017, 0.309017, -0.5],
596
- [-0.864188, -0.442863, -0.238856],
597
- [-0.951056, -0.16246, -0.262866],
598
- [-0.809017, -0.309017, -0.5],
599
- [-0.681718, 0.147621, -0.716567],
600
- [-0.681718, -0.147621, -0.716567],
601
- [-0.850651, 0, -0.525731],
602
- [-0.688191, 0.587785, -0.425325],
603
- [-0.587785, 0.425325, -0.688191],
604
- [-0.425325, 0.688191, -0.587785],
605
- [-0.425325, -0.688191, -0.587785],
606
- [-0.587785, -0.425325, -0.688191],
607
- [-0.688191, -0.587785, -0.425325]
608
- ];
609
- function createMat4Identity() {
610
- return new Float32Array([
611
- 1,
612
- 0,
613
- 0,
614
- 0,
615
- 0,
616
- 1,
617
- 0,
618
- 0,
619
- 0,
620
- 0,
621
- 1,
622
- 0,
623
- 0,
624
- 0,
625
- 0,
626
- 1
627
- ]);
628
- }
629
- function transformPointMat4(mat, point) {
630
- const x = point.x;
631
- const y = point.y;
632
- const z = point.z;
633
- return {
634
- x: mat[0] * x + mat[4] * y + mat[8] * z + mat[12],
635
- y: mat[1] * x + mat[5] * y + mat[9] * z + mat[13],
636
- z: mat[2] * x + mat[6] * y + mat[10] * z + mat[14]
637
- };
638
- }
639
- function mat4FromBasis(origin, axis) {
640
- const out = createMat4Identity();
641
- out[0] = axis[0].x;
642
- out[1] = axis[0].y;
643
- out[2] = axis[0].z;
644
- out[4] = axis[1].x;
645
- out[5] = axis[1].y;
646
- out[6] = axis[1].z;
647
- out[8] = axis[2].x;
648
- out[9] = axis[2].y;
649
- out[10] = axis[2].z;
650
- out[12] = origin.x;
651
- out[13] = origin.y;
652
- out[14] = origin.z;
653
- return out;
654
- }
655
- var CONTENTS_SOLID = 1 << 0;
656
- var CONTENTS_WINDOW = 1 << 1;
657
- var CONTENTS_AUX = 1 << 2;
658
- var CONTENTS_LAVA = 1 << 3;
659
- var CONTENTS_SLIME = 1 << 4;
660
- var CONTENTS_WATER = 1 << 5;
661
- var CONTENTS_MIST = 1 << 6;
662
- var CONTENTS_NO_WATERJUMP = 1 << 13;
663
- var CONTENTS_PROJECTILECLIP = 1 << 14;
664
- var CONTENTS_AREAPORTAL = 1 << 15;
665
- var CONTENTS_PLAYERCLIP = 1 << 16;
666
- var CONTENTS_MONSTERCLIP = 1 << 17;
667
- var CONTENTS_CURRENT_0 = 1 << 18;
668
- var CONTENTS_CURRENT_90 = 1 << 19;
669
- var CONTENTS_CURRENT_180 = 1 << 20;
670
- var CONTENTS_CURRENT_270 = 1 << 21;
671
- var CONTENTS_CURRENT_UP = 1 << 22;
672
- var CONTENTS_CURRENT_DOWN = 1 << 23;
673
- var CONTENTS_ORIGIN = 1 << 24;
674
- var CONTENTS_MONSTER = 1 << 25;
675
- var CONTENTS_DEADMONSTER = 1 << 26;
676
- var CONTENTS_DETAIL = 1 << 27;
677
- var CONTENTS_TRANSLUCENT = 1 << 28;
678
- var CONTENTS_LADDER = 1 << 29;
679
- var CONTENTS_PLAYER = 1 << 30;
680
- var CONTENTS_PROJECTILE = 1 << 31;
681
- var SURF_NONE = 0;
682
- var SURF_LIGHT = 1 << 0;
683
- var SURF_SLICK = 1 << 1;
684
- var SURF_SKY = 1 << 2;
685
- var SURF_WARP = 1 << 3;
686
- var SURF_TRANS33 = 1 << 4;
687
- var SURF_TRANS66 = 1 << 5;
688
- var SURF_FLOWING = 1 << 6;
689
- var SURF_NODRAW = 1 << 7;
690
- var SURF_ALPHATEST = 1 << 25;
691
- var SURF_N64_UV = 1 << 28;
692
- var SURF_N64_SCROLL_X = 1 << 29;
693
- var SURF_N64_SCROLL_Y = 1 << 30;
694
- var SURF_N64_SCROLL_FLIP = 1 << 31;
695
- var MASK_SOLID = CONTENTS_SOLID | CONTENTS_WINDOW;
696
- var MASK_PLAYERSOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_PLAYER;
697
- var MASK_DEADSOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW;
698
- var MASK_MONSTERSOLID = CONTENTS_SOLID | CONTENTS_MONSTERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_PLAYER;
699
- var MASK_WATER = CONTENTS_WATER | CONTENTS_LAVA | CONTENTS_SLIME;
700
- var MASK_OPAQUE = CONTENTS_SOLID | CONTENTS_SLIME | CONTENTS_LAVA;
701
- var MASK_SHOT = CONTENTS_SOLID | CONTENTS_MONSTER | CONTENTS_PLAYER | CONTENTS_WINDOW | CONTENTS_DEADMONSTER;
702
- var MASK_CURRENT = CONTENTS_CURRENT_0 | CONTENTS_CURRENT_90 | CONTENTS_CURRENT_180 | CONTENTS_CURRENT_270 | CONTENTS_CURRENT_UP | CONTENTS_CURRENT_DOWN;
703
- var MASK_BLOCK_SIGHT = CONTENTS_SOLID | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_MONSTER | CONTENTS_PLAYER;
704
- var MASK_NAV_SOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW;
705
- var MASK_LADDER_NAV_SOLID = CONTENTS_SOLID | CONTENTS_WINDOW;
706
- var MASK_WALK_NAV_SOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP;
707
- var MASK_PROJECTILE = MASK_SHOT | CONTENTS_PROJECTILECLIP;
708
- var MAX_CHECKCOUNT = Number.MAX_SAFE_INTEGER - 1;
709
- var CvarFlags = /* @__PURE__ */ ((CvarFlags2) => {
710
- CvarFlags2[CvarFlags2["None"] = 0] = "None";
711
- CvarFlags2[CvarFlags2["Archive"] = 1] = "Archive";
712
- CvarFlags2[CvarFlags2["UserInfo"] = 2] = "UserInfo";
713
- CvarFlags2[CvarFlags2["ServerInfo"] = 4] = "ServerInfo";
714
- CvarFlags2[CvarFlags2["Latch"] = 8] = "Latch";
715
- CvarFlags2[CvarFlags2["Cheat"] = 16] = "Cheat";
716
- return CvarFlags2;
717
- })(CvarFlags || {});
718
- var MAX_CLIENTS = 256;
719
- var MAX_LIGHTSTYLES = 256;
720
- var MAX_MODELS = 8192;
721
- var MAX_SOUNDS = 2048;
722
- var MAX_IMAGES = 512;
723
- var MAX_ITEMS = 256;
724
- var MAX_GENERAL = MAX_CLIENTS * 2;
725
- var MAX_SHADOW_LIGHTS = 256;
726
- var MAX_WHEEL_ITEMS = 32;
727
- var CS_MAX_STRING_LENGTH = 96;
728
- var ConfigStringIndex = ((ConfigStringIndex2) => {
729
- ConfigStringIndex2[ConfigStringIndex2["Name"] = 0] = "Name";
730
- ConfigStringIndex2[ConfigStringIndex2["CdTrack"] = 1] = "CdTrack";
731
- ConfigStringIndex2[ConfigStringIndex2["Sky"] = 2] = "Sky";
732
- ConfigStringIndex2[ConfigStringIndex2["SkyAxis"] = 3] = "SkyAxis";
733
- ConfigStringIndex2[ConfigStringIndex2["SkyRotate"] = 4] = "SkyRotate";
734
- ConfigStringIndex2[ConfigStringIndex2["StatusBar"] = 5] = "StatusBar";
735
- ConfigStringIndex2[ConfigStringIndex2["HealthBarName"] = 55] = "HealthBarName";
736
- ConfigStringIndex2[ConfigStringIndex2["CONFIG_N64_PHYSICS"] = 56] = "CONFIG_N64_PHYSICS";
737
- ConfigStringIndex2[ConfigStringIndex2["CONFIG_CTF_TEAMS"] = 57] = "CONFIG_CTF_TEAMS";
738
- ConfigStringIndex2[ConfigStringIndex2["CONFIG_COOP_RESPAWN_STRING"] = 58] = "CONFIG_COOP_RESPAWN_STRING";
739
- ConfigStringIndex2[ConfigStringIndex2["Story"] = 54] = "Story";
740
- ConfigStringIndex2[ConfigStringIndex2["AirAccel"] = 59] = "AirAccel";
741
- ConfigStringIndex2[ConfigStringIndex2["MaxClients"] = 60] = "MaxClients";
742
- ConfigStringIndex2[ConfigStringIndex2["MapChecksum"] = 61] = "MapChecksum";
743
- ConfigStringIndex2[ConfigStringIndex2["Models"] = 62] = "Models";
744
- ConfigStringIndex2[ConfigStringIndex2["Sounds"] = 62 + MAX_MODELS] = "Sounds";
745
- ConfigStringIndex2[ConfigStringIndex2["Images"] = ConfigStringIndex2.Sounds + MAX_SOUNDS] = "Images";
746
- ConfigStringIndex2[ConfigStringIndex2["Lights"] = ConfigStringIndex2.Images + MAX_IMAGES] = "Lights";
747
- ConfigStringIndex2[ConfigStringIndex2["ShadowLights"] = ConfigStringIndex2.Lights + MAX_LIGHTSTYLES] = "ShadowLights";
748
- ConfigStringIndex2[ConfigStringIndex2["Items"] = ConfigStringIndex2.ShadowLights + MAX_SHADOW_LIGHTS] = "Items";
749
- ConfigStringIndex2[ConfigStringIndex2["Players"] = ConfigStringIndex2.Items + MAX_ITEMS] = "Players";
750
- ConfigStringIndex2[ConfigStringIndex2["PlayerSkins"] = ConfigStringIndex2.Players] = "PlayerSkins";
751
- ConfigStringIndex2[ConfigStringIndex2["General"] = ConfigStringIndex2.Players + MAX_CLIENTS] = "General";
752
- ConfigStringIndex2[ConfigStringIndex2["WheelWeapons"] = ConfigStringIndex2.General + MAX_GENERAL] = "WheelWeapons";
753
- ConfigStringIndex2[ConfigStringIndex2["WheelAmmo"] = ConfigStringIndex2.WheelWeapons + MAX_WHEEL_ITEMS] = "WheelAmmo";
754
- ConfigStringIndex2[ConfigStringIndex2["WheelPowerups"] = ConfigStringIndex2.WheelAmmo + MAX_WHEEL_ITEMS] = "WheelPowerups";
755
- ConfigStringIndex2[ConfigStringIndex2["CdLoopCount"] = ConfigStringIndex2.WheelPowerups + MAX_WHEEL_ITEMS] = "CdLoopCount";
756
- ConfigStringIndex2[ConfigStringIndex2["GameStyle"] = ConfigStringIndex2.CdLoopCount + 1] = "GameStyle";
757
- ConfigStringIndex2[ConfigStringIndex2["MaxConfigStrings"] = ConfigStringIndex2.GameStyle + 1] = "MaxConfigStrings";
758
- return ConfigStringIndex2;
759
- })(ConfigStringIndex || {});
760
- var MAX_CONFIGSTRINGS = ConfigStringIndex.MaxConfigStrings;
761
- function configStringSize(index) {
762
- if (index >= 5 && index < 59) {
763
- return CS_MAX_STRING_LENGTH * (59 - index);
764
- }
765
- if (index >= ConfigStringIndex.General && index < ConfigStringIndex.WheelWeapons) {
766
- return CS_MAX_STRING_LENGTH * (ConfigStringIndex.MaxConfigStrings - index);
767
- }
768
- return CS_MAX_STRING_LENGTH;
769
- }
770
- var CS_SOUNDS = ConfigStringIndex.Sounds;
771
- var CS_IMAGES = ConfigStringIndex.Images;
772
- var CS_LIGHTS = ConfigStringIndex.Lights;
773
- var CS_ITEMS = ConfigStringIndex.Items;
774
- var CS_PLAYERS = ConfigStringIndex.Players;
775
- var CS_GENERAL = ConfigStringIndex.General;
776
- var replay_exports = {};
777
- __export2(replay_exports, {
778
- addReplayFrame: () => addReplayFrame,
779
- createReplaySession: () => createReplaySession,
780
- deserializeReplay: () => deserializeReplay,
781
- serializeReplay: () => serializeReplay
782
- });
783
- function serializeReplay(session) {
784
- return JSON.stringify(session, null, 2);
785
- }
786
- function deserializeReplay(json) {
787
- const session = JSON.parse(json);
788
- if (!session.metadata || !Array.isArray(session.frames)) {
789
- throw new Error("Invalid replay format: missing metadata or frames");
790
- }
791
- return session;
792
- }
793
- function createReplaySession(map, seed) {
794
- return {
795
- metadata: {
796
- map,
797
- date: (/* @__PURE__ */ new Date()).toISOString(),
798
- version: "1.0",
799
- seed
800
- },
801
- frames: []
802
- };
803
- }
804
- function addReplayFrame(session, cmd, serverFrame, startTime) {
805
- session.frames.push({
806
- serverFrame,
807
- cmd,
808
- timestamp: Date.now() - startTime
809
- });
810
- }
811
- var WATERJUMP_CLEAR = 8 | 16 | 32 | 1024;
812
- var ServerCommand = /* @__PURE__ */ ((ServerCommand2) => {
813
- ServerCommand2[ServerCommand2["bad"] = 0] = "bad";
814
- ServerCommand2[ServerCommand2["muzzleflash"] = 1] = "muzzleflash";
815
- ServerCommand2[ServerCommand2["muzzleflash2"] = 2] = "muzzleflash2";
816
- ServerCommand2[ServerCommand2["temp_entity"] = 3] = "temp_entity";
817
- ServerCommand2[ServerCommand2["layout"] = 4] = "layout";
818
- ServerCommand2[ServerCommand2["inventory"] = 5] = "inventory";
819
- ServerCommand2[ServerCommand2["nop"] = 6] = "nop";
820
- ServerCommand2[ServerCommand2["disconnect"] = 7] = "disconnect";
821
- ServerCommand2[ServerCommand2["reconnect"] = 8] = "reconnect";
822
- ServerCommand2[ServerCommand2["sound"] = 9] = "sound";
823
- ServerCommand2[ServerCommand2["print"] = 10] = "print";
824
- ServerCommand2[ServerCommand2["stufftext"] = 11] = "stufftext";
825
- ServerCommand2[ServerCommand2["serverdata"] = 12] = "serverdata";
826
- ServerCommand2[ServerCommand2["configstring"] = 13] = "configstring";
827
- ServerCommand2[ServerCommand2["spawnbaseline"] = 14] = "spawnbaseline";
828
- ServerCommand2[ServerCommand2["centerprint"] = 15] = "centerprint";
829
- ServerCommand2[ServerCommand2["download"] = 16] = "download";
830
- ServerCommand2[ServerCommand2["playerinfo"] = 17] = "playerinfo";
831
- ServerCommand2[ServerCommand2["packetentities"] = 18] = "packetentities";
832
- ServerCommand2[ServerCommand2["deltapacketentities"] = 19] = "deltapacketentities";
833
- ServerCommand2[ServerCommand2["frame"] = 20] = "frame";
834
- ServerCommand2[ServerCommand2["splitclient"] = 21] = "splitclient";
835
- ServerCommand2[ServerCommand2["configblast"] = 22] = "configblast";
836
- ServerCommand2[ServerCommand2["spawnbaselineblast"] = 23] = "spawnbaselineblast";
837
- ServerCommand2[ServerCommand2["level_restart"] = 24] = "level_restart";
838
- ServerCommand2[ServerCommand2["damage"] = 25] = "damage";
839
- ServerCommand2[ServerCommand2["locprint"] = 26] = "locprint";
840
- ServerCommand2[ServerCommand2["fog"] = 27] = "fog";
841
- ServerCommand2[ServerCommand2["waitingforplayers"] = 28] = "waitingforplayers";
842
- ServerCommand2[ServerCommand2["bot_chat"] = 29] = "bot_chat";
843
- ServerCommand2[ServerCommand2["poi"] = 30] = "poi";
844
- ServerCommand2[ServerCommand2["help_path"] = 31] = "help_path";
845
- ServerCommand2[ServerCommand2["muzzleflash3"] = 32] = "muzzleflash3";
846
- ServerCommand2[ServerCommand2["achievement"] = 33] = "achievement";
847
- return ServerCommand2;
848
- })(ServerCommand || {});
849
- var ClientCommand = /* @__PURE__ */ ((ClientCommand2) => {
850
- ClientCommand2[ClientCommand2["bad"] = 0] = "bad";
851
- ClientCommand2[ClientCommand2["nop"] = 1] = "nop";
852
- ClientCommand2[ClientCommand2["move"] = 2] = "move";
853
- ClientCommand2[ClientCommand2["userinfo"] = 3] = "userinfo";
854
- ClientCommand2[ClientCommand2["stringcmd"] = 4] = "stringcmd";
855
- return ClientCommand2;
856
- })(ClientCommand || {});
857
- var TempEntity = /* @__PURE__ */ ((TempEntity2) => {
858
- TempEntity2[TempEntity2["GUNSHOT"] = 0] = "GUNSHOT";
859
- TempEntity2[TempEntity2["BLOOD"] = 1] = "BLOOD";
860
- TempEntity2[TempEntity2["BLASTER"] = 2] = "BLASTER";
861
- TempEntity2[TempEntity2["RAILTRAIL"] = 3] = "RAILTRAIL";
862
- TempEntity2[TempEntity2["SHOTGUN"] = 4] = "SHOTGUN";
863
- TempEntity2[TempEntity2["EXPLOSION1"] = 5] = "EXPLOSION1";
864
- TempEntity2[TempEntity2["EXPLOSION2"] = 6] = "EXPLOSION2";
865
- TempEntity2[TempEntity2["ROCKET_EXPLOSION"] = 7] = "ROCKET_EXPLOSION";
866
- TempEntity2[TempEntity2["GRENADE_EXPLOSION"] = 8] = "GRENADE_EXPLOSION";
867
- TempEntity2[TempEntity2["SPARKS"] = 9] = "SPARKS";
868
- TempEntity2[TempEntity2["SPLASH"] = 10] = "SPLASH";
869
- TempEntity2[TempEntity2["BUBBLETRAIL"] = 11] = "BUBBLETRAIL";
870
- TempEntity2[TempEntity2["SCREEN_SPARKS"] = 12] = "SCREEN_SPARKS";
871
- TempEntity2[TempEntity2["SHIELD_SPARKS"] = 13] = "SHIELD_SPARKS";
872
- TempEntity2[TempEntity2["BULLET_SPARKS"] = 14] = "BULLET_SPARKS";
873
- TempEntity2[TempEntity2["LASER_SPARKS"] = 15] = "LASER_SPARKS";
874
- TempEntity2[TempEntity2["PARASITE_ATTACK"] = 16] = "PARASITE_ATTACK";
875
- TempEntity2[TempEntity2["ROCKET_EXPLOSION_WATER"] = 17] = "ROCKET_EXPLOSION_WATER";
876
- TempEntity2[TempEntity2["GRENADE_EXPLOSION_WATER"] = 18] = "GRENADE_EXPLOSION_WATER";
877
- TempEntity2[TempEntity2["MEDIC_CABLE_ATTACK"] = 19] = "MEDIC_CABLE_ATTACK";
878
- TempEntity2[TempEntity2["BFG_EXPLOSION"] = 20] = "BFG_EXPLOSION";
879
- TempEntity2[TempEntity2["BFG_BIGEXPLOSION"] = 21] = "BFG_BIGEXPLOSION";
880
- TempEntity2[TempEntity2["BOSSTPORT"] = 22] = "BOSSTPORT";
881
- TempEntity2[TempEntity2["BFG_LASER"] = 23] = "BFG_LASER";
882
- TempEntity2[TempEntity2["GRAPPLE_CABLE"] = 24] = "GRAPPLE_CABLE";
883
- TempEntity2[TempEntity2["WELDING_SPARKS"] = 25] = "WELDING_SPARKS";
884
- TempEntity2[TempEntity2["GREENBLOOD"] = 26] = "GREENBLOOD";
885
- TempEntity2[TempEntity2["BLUEHYPERBLASTER"] = 27] = "BLUEHYPERBLASTER";
886
- TempEntity2[TempEntity2["PLASMA_EXPLOSION"] = 28] = "PLASMA_EXPLOSION";
887
- TempEntity2[TempEntity2["TUNNEL_SPARKS"] = 29] = "TUNNEL_SPARKS";
888
- TempEntity2[TempEntity2["BLASTER2"] = 30] = "BLASTER2";
889
- TempEntity2[TempEntity2["RAILTRAIL2"] = 31] = "RAILTRAIL2";
890
- TempEntity2[TempEntity2["FLAME"] = 32] = "FLAME";
891
- TempEntity2[TempEntity2["LIGHTNING"] = 33] = "LIGHTNING";
892
- TempEntity2[TempEntity2["DEBUGTRAIL"] = 34] = "DEBUGTRAIL";
893
- TempEntity2[TempEntity2["PLAIN_EXPLOSION"] = 35] = "PLAIN_EXPLOSION";
894
- TempEntity2[TempEntity2["FLASHLIGHT"] = 36] = "FLASHLIGHT";
895
- TempEntity2[TempEntity2["FORCEWALL"] = 37] = "FORCEWALL";
896
- TempEntity2[TempEntity2["HEATBEAM"] = 38] = "HEATBEAM";
897
- TempEntity2[TempEntity2["MONSTER_HEATBEAM"] = 39] = "MONSTER_HEATBEAM";
898
- TempEntity2[TempEntity2["STEAM"] = 40] = "STEAM";
899
- TempEntity2[TempEntity2["BUBBLETRAIL2"] = 41] = "BUBBLETRAIL2";
900
- TempEntity2[TempEntity2["MOREBLOOD"] = 42] = "MOREBLOOD";
901
- TempEntity2[TempEntity2["HEATBEAM_SPARKS"] = 43] = "HEATBEAM_SPARKS";
902
- TempEntity2[TempEntity2["HEATBEAM_STEAM"] = 44] = "HEATBEAM_STEAM";
903
- TempEntity2[TempEntity2["CHAINFIST_SMOKE"] = 45] = "CHAINFIST_SMOKE";
904
- TempEntity2[TempEntity2["ELECTRIC_SPARKS"] = 46] = "ELECTRIC_SPARKS";
905
- TempEntity2[TempEntity2["TRACKER_EXPLOSION"] = 47] = "TRACKER_EXPLOSION";
906
- TempEntity2[TempEntity2["TELEPORT_EFFECT"] = 48] = "TELEPORT_EFFECT";
907
- TempEntity2[TempEntity2["DBALL_GOAL"] = 49] = "DBALL_GOAL";
908
- TempEntity2[TempEntity2["WIDOWBEAMOUT"] = 50] = "WIDOWBEAMOUT";
909
- TempEntity2[TempEntity2["NUKEBLAST"] = 51] = "NUKEBLAST";
910
- TempEntity2[TempEntity2["WIDOWSPLASH"] = 52] = "WIDOWSPLASH";
911
- TempEntity2[TempEntity2["EXPLOSION1_BIG"] = 53] = "EXPLOSION1_BIG";
912
- TempEntity2[TempEntity2["EXPLOSION1_NP"] = 54] = "EXPLOSION1_NP";
913
- TempEntity2[TempEntity2["FLECHETTE"] = 55] = "FLECHETTE";
914
- TempEntity2[TempEntity2["BLUEHYPERBLASTER_KEX"] = 56] = "BLUEHYPERBLASTER_KEX";
915
- TempEntity2[TempEntity2["BFG_ZAP"] = 57] = "BFG_ZAP";
916
- TempEntity2[TempEntity2["BERSERK_SLAM"] = 58] = "BERSERK_SLAM";
917
- TempEntity2[TempEntity2["GRAPPLE_CABLE_2"] = 59] = "GRAPPLE_CABLE_2";
918
- TempEntity2[TempEntity2["POWER_SPLASH"] = 60] = "POWER_SPLASH";
919
- TempEntity2[TempEntity2["LIGHTNING_BEAM"] = 61] = "LIGHTNING_BEAM";
920
- TempEntity2[TempEntity2["EXPLOSION1_NL"] = 62] = "EXPLOSION1_NL";
921
- TempEntity2[TempEntity2["EXPLOSION2_NL"] = 63] = "EXPLOSION2_NL";
922
- return TempEntity2;
923
- })(TempEntity || {});
924
- var CMD_BACKUP = 64;
925
- var AMMO_MAX = 12;
926
- var NUM_BITS_FOR_AMMO = 9;
927
- var NUM_AMMO_STATS = Math.ceil(AMMO_MAX * NUM_BITS_FOR_AMMO / 16);
928
- var POWERUP_MAX = 23;
929
- var NUM_BITS_FOR_POWERUP = 2;
930
- var NUM_POWERUP_STATS = Math.ceil(POWERUP_MAX * NUM_BITS_FOR_POWERUP / 16);
931
- function writeUserCommand(writer, cmd) {
932
- writer.writeByte(cmd.msec);
933
- writer.writeByte(cmd.buttons);
934
- writer.writeAngle16(cmd.angles.x);
935
- writer.writeAngle16(cmd.angles.y);
936
- writer.writeAngle16(cmd.angles.z);
937
- writer.writeShort(cmd.forwardmove);
938
- writer.writeShort(cmd.sidemove);
939
- writer.writeShort(cmd.upmove);
940
- writer.writeByte(cmd.impulse);
941
- writer.writeByte(0);
942
- }
943
- var crc_table = [
944
- 0,
945
- 145,
946
- 227,
947
- 114,
948
- 7,
949
- 150,
950
- 228,
951
- 117,
952
- 14,
953
- 159,
954
- 237,
955
- 124,
956
- 9,
957
- 152,
958
- 234,
959
- 123,
960
- 28,
961
- 141,
962
- 255,
963
- 110,
964
- 27,
965
- 138,
966
- 248,
967
- 105,
968
- 18,
969
- 131,
970
- 241,
971
- 96,
972
- 21,
973
- 132,
974
- 246,
975
- 103,
976
- 56,
977
- 169,
978
- 219,
979
- 74,
980
- 63,
981
- 174,
982
- 220,
983
- 77,
984
- 54,
985
- 167,
986
- 213,
987
- 68,
988
- 49,
989
- 160,
990
- 210,
991
- 67,
992
- 36,
993
- 181,
994
- 199,
995
- 86,
996
- 35,
997
- 178,
998
- 192,
999
- 81,
1000
- 42,
1001
- 187,
1002
- 201,
1003
- 88,
1004
- 45,
1005
- 188,
1006
- 206,
1007
- 95,
1008
- 112,
1009
- 225,
1010
- 147,
1011
- 2,
1012
- 119,
1013
- 230,
1014
- 148,
1015
- 5,
1016
- 126,
1017
- 239,
1018
- 157,
1019
- 12,
1020
- 121,
1021
- 232,
1022
- 154,
1023
- 11,
1024
- 108,
1025
- 253,
1026
- 143,
1027
- 30,
1028
- 107,
1029
- 250,
1030
- 136,
1031
- 25,
1032
- 98,
1033
- 243,
1034
- 129,
1035
- 16,
1036
- 101,
1037
- 244,
1038
- 134,
1039
- 23,
1040
- 72,
1041
- 217,
1042
- 171,
1043
- 58,
1044
- 79,
1045
- 222,
1046
- 172,
1047
- 61,
1048
- 70,
1049
- 215,
1050
- 165,
1051
- 52,
1052
- 65,
1053
- 208,
1054
- 162,
1055
- 51,
1056
- 84,
1057
- 197,
1058
- 183,
1059
- 38,
1060
- 83,
1061
- 194,
1062
- 176,
1063
- 33,
1064
- 90,
1065
- 203,
1066
- 185,
1067
- 40,
1068
- 93,
1069
- 204,
1070
- 190,
1071
- 47,
1072
- 224,
1073
- 113,
1074
- 3,
1075
- 146,
1076
- 231,
1077
- 118,
1078
- 4,
1079
- 149,
1080
- 238,
1081
- 127,
1082
- 13,
1083
- 156,
1084
- 233,
1085
- 120,
1086
- 10,
1087
- 155,
1088
- 252,
1089
- 109,
1090
- 31,
1091
- 142,
1092
- 251,
1093
- 106,
1094
- 24,
1095
- 137,
1096
- 242,
1097
- 99,
1098
- 17,
1099
- 128,
1100
- 245,
1101
- 100,
1102
- 22,
1103
- 135,
1104
- 216,
1105
- 73,
1106
- 59,
1107
- 170,
1108
- 223,
1109
- 78,
1110
- 60,
1111
- 173,
1112
- 214,
1113
- 71,
1114
- 53,
1115
- 164,
1116
- 209,
1117
- 64,
1118
- 50,
1119
- 163,
1120
- 196,
1121
- 85,
1122
- 39,
1123
- 182,
1124
- 195,
1125
- 82,
1126
- 32,
1127
- 177,
1128
- 202,
1129
- 91,
1130
- 41,
1131
- 184,
1132
- 205,
1133
- 92,
1134
- 46,
1135
- 191,
1136
- 144,
1137
- 1,
1138
- 115,
1139
- 226,
1140
- 151,
1141
- 6,
1142
- 116,
1143
- 229,
1144
- 158,
1145
- 15,
1146
- 125,
1147
- 236,
1148
- 153,
1149
- 8,
1150
- 122,
1151
- 235,
1152
- 140,
1153
- 29,
1154
- 111,
1155
- 254,
1156
- 139,
1157
- 26,
1158
- 104,
1159
- 249,
1160
- 130,
1161
- 19,
1162
- 97,
1163
- 240,
1164
- 133,
1165
- 20,
1166
- 102,
1167
- 247,
1168
- 168,
1169
- 57,
1170
- 75,
1171
- 218,
1172
- 175,
1173
- 62,
1174
- 76,
1175
- 221,
1176
- 166,
1177
- 55,
1178
- 69,
1179
- 212,
1180
- 161,
1181
- 48,
1182
- 66,
1183
- 211,
1184
- 180,
1185
- 37,
1186
- 86,
1187
- 199,
1188
- 179,
1189
- 34,
1190
- 80,
1191
- 193,
1192
- 186,
1193
- 43,
1194
- 89,
1195
- 200,
1196
- 189,
1197
- 44,
1198
- 94,
1199
- 207
1200
- ];
1201
- function crc8(data) {
1202
- let crc = 0;
1203
- for (let i = 0; i < data.length; i++) {
1204
- crc = crc_table[(crc ^ data[i]) & 255];
1205
- }
1206
- return crc;
1207
- }
1208
- var U_ORIGIN1 = 1 << 0;
1209
- var U_ORIGIN2 = 1 << 1;
1210
- var U_ANGLE2 = 1 << 2;
1211
- var U_ANGLE3 = 1 << 3;
1212
- var U_FRAME8 = 1 << 4;
1213
- var U_EVENT = 1 << 5;
1214
- var U_REMOVE = 1 << 6;
1215
- var U_MOREBITS1 = 1 << 7;
1216
- var U_NUMBER16 = 1 << 8;
1217
- var U_ORIGIN3 = 1 << 9;
1218
- var U_ANGLE1 = 1 << 10;
1219
- var U_MODEL = 1 << 11;
1220
- var U_RENDERFX8 = 1 << 12;
1221
- var U_ALPHA = 1 << 13;
1222
- var U_EFFECTS8 = 1 << 14;
1223
- var U_MOREBITS2 = 1 << 15;
1224
- var U_SKIN8 = 1 << 16;
1225
- var U_FRAME16 = 1 << 17;
1226
- var U_RENDERFX16 = 1 << 18;
1227
- var U_EFFECTS16 = 1 << 19;
1228
- var U_MODEL2 = 1 << 20;
1229
- var U_MODEL3 = 1 << 21;
1230
- var U_MODEL4 = 1 << 22;
1231
- var U_MOREBITS3 = 1 << 23;
1232
- var U_OLDORIGIN = 1 << 24;
1233
- var U_SKIN16 = 1 << 25;
1234
- var U_SOUND = 1 << 26;
1235
- var U_SOLID = 1 << 27;
1236
- var U_SCALE = 1 << 28;
1237
- var U_INSTANCE_BITS = 1 << 29;
1238
- var U_LOOP_VOLUME = 1 << 30;
1239
- var U_MOREBITS4 = 2147483648 | 0;
1240
- var U_LOOP_ATTENUATION_HIGH = 1 << 0;
1241
- var U_OWNER_HIGH = 1 << 1;
1242
- var U_OLD_FRAME_HIGH = 1 << 2;
1243
- var PS_M_TYPE = 1 << 0;
1244
- var PS_M_ORIGIN = 1 << 1;
1245
- var PS_M_VELOCITY = 1 << 2;
1246
- var PS_M_TIME = 1 << 3;
1247
- var PS_M_FLAGS = 1 << 4;
1248
- var PS_M_GRAVITY = 1 << 5;
1249
- var PS_M_DELTA_ANGLES = 1 << 6;
1250
- var PS_VIEWOFFSET = 1 << 7;
1251
- var PS_VIEWANGLES = 1 << 8;
1252
- var PS_KICKANGLES = 1 << 9;
1253
- var PS_BLEND = 1 << 10;
1254
- var PS_FOV = 1 << 11;
1255
- var PS_WEAPONINDEX = 1 << 12;
1256
- var PS_WEAPONFRAME = 1 << 13;
1257
- var PS_RDFLAGS = 1 << 14;
1258
- var PS_WATERTYPE = 1 << 15;
1259
- var BinaryStream = class {
1260
- constructor(buffer) {
1261
- if (buffer instanceof Uint8Array) {
1262
- this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
1263
- } else {
1264
- this.view = new DataView(buffer);
1265
- }
1266
- this.offset = 0;
1267
- this.length = this.view.byteLength;
1268
- }
1269
- getPosition() {
1270
- return this.offset;
1271
- }
1272
- getReadPosition() {
1273
- return this.offset;
1274
- }
1275
- getLength() {
1276
- return this.length;
1277
- }
1278
- getRemaining() {
1279
- return this.length - this.offset;
1280
- }
1281
- seek(position) {
1282
- if (position < 0 || position > this.length) {
1283
- throw new Error(`Seek out of bounds: ${position} (length: ${this.length})`);
1284
- }
1285
- this.offset = position;
1286
- }
1287
- setReadPosition(position) {
1288
- this.seek(position);
1289
- }
1290
- hasMore() {
1291
- return this.offset < this.length;
1292
- }
1293
- hasBytes(count) {
1294
- return this.offset + count <= this.length;
1295
- }
1296
- readChar() {
1297
- const value = this.view.getInt8(this.offset);
1298
- this.offset += 1;
1299
- return value;
1300
- }
1301
- readByte() {
1302
- const value = this.view.getUint8(this.offset);
1303
- this.offset += 1;
1304
- return value;
1305
- }
1306
- readShort() {
1307
- const value = this.view.getInt16(this.offset, true);
1308
- this.offset += 2;
1309
- return value;
1310
- }
1311
- readUShort() {
1312
- const value = this.view.getUint16(this.offset, true);
1313
- this.offset += 2;
1314
- return value;
1315
- }
1316
- readLong() {
1317
- const value = this.view.getInt32(this.offset, true);
1318
- this.offset += 4;
1319
- return value;
1320
- }
1321
- readULong() {
1322
- const value = this.view.getUint32(this.offset, true);
1323
- this.offset += 4;
1324
- return value;
1325
- }
1326
- readFloat() {
1327
- const value = this.view.getFloat32(this.offset, true);
1328
- this.offset += 4;
1329
- return value;
1330
- }
1331
- readString() {
1332
- let str = "";
1333
- while (this.offset < this.length) {
1334
- const charCode = this.readChar();
1335
- if (charCode === -1 || charCode === 0) {
1336
- break;
1337
- }
1338
- str += String.fromCharCode(charCode);
1339
- }
1340
- return str;
1341
- }
1342
- readStringLine() {
1343
- let str = "";
1344
- while (this.offset < this.length) {
1345
- const charCode = this.readChar();
1346
- if (charCode === -1 || charCode === 0 || charCode === 10) {
1347
- break;
1348
- }
1349
- str += String.fromCharCode(charCode);
1350
- }
1351
- return str;
1352
- }
1353
- readCoord() {
1354
- return this.readShort() * (1 / 8);
1355
- }
1356
- readAngle() {
1357
- return this.readChar() * (360 / 256);
1358
- }
1359
- readAngle16() {
1360
- return this.readShort() * 360 / 65536;
1361
- }
1362
- readData(length) {
1363
- if (this.offset + length > this.length) {
1364
- throw new Error(`Read out of bounds: ${this.offset + length} (length: ${this.length})`);
1365
- }
1366
- const data = new Uint8Array(this.view.buffer, this.view.byteOffset + this.offset, length);
1367
- this.offset += length;
1368
- return new Uint8Array(data);
1369
- }
1370
- readPos(out) {
1371
- out.x = this.readCoord();
1372
- out.y = this.readCoord();
1373
- out.z = this.readCoord();
1374
- }
1375
- readDir(out) {
1376
- const b = this.readByte();
1377
- if (b >= 162) {
1378
- out.x = 0;
1379
- out.y = 0;
1380
- out.z = 0;
1381
- return;
1382
- }
1383
- const norm = ANORMS[b];
1384
- out.x = norm[0];
1385
- out.y = norm[1];
1386
- out.z = norm[2];
1387
- }
1388
- };
1389
- var BinaryWriter = class {
1390
- constructor(sizeOrBuffer = 1400) {
1391
- if (typeof sizeOrBuffer === "number") {
1392
- this.buffer = new Uint8Array(sizeOrBuffer);
1393
- this.fixed = false;
1394
- } else {
1395
- this.buffer = sizeOrBuffer;
1396
- this.fixed = true;
1397
- }
1398
- this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
1399
- this.offset = 0;
1400
- }
1401
- ensureSpace(bytes) {
1402
- if (this.offset + bytes > this.buffer.byteLength) {
1403
- if (this.fixed) {
1404
- throw new Error(`Buffer overflow: capacity ${this.buffer.byteLength}, needed ${this.offset + bytes}`);
1405
- }
1406
- const newSize = Math.max(this.buffer.byteLength * 2, this.offset + bytes);
1407
- const newBuffer = new Uint8Array(newSize);
1408
- newBuffer.set(this.buffer);
1409
- this.buffer = newBuffer;
1410
- this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
1411
- }
1412
- }
1413
- writeByte(value) {
1414
- this.ensureSpace(1);
1415
- this.view.setUint8(this.offset, value);
1416
- this.offset += 1;
1417
- }
1418
- writeBytes(data) {
1419
- this.ensureSpace(data.byteLength);
1420
- this.buffer.set(data, this.offset);
1421
- this.offset += data.byteLength;
1422
- }
1423
- writeChar(value) {
1424
- this.ensureSpace(1);
1425
- this.view.setInt8(this.offset, value);
1426
- this.offset += 1;
1427
- }
1428
- writeShort(value) {
1429
- this.ensureSpace(2);
1430
- this.view.setInt16(this.offset, value, true);
1431
- this.offset += 2;
1432
- }
1433
- writeLong(value) {
1434
- this.ensureSpace(4);
1435
- this.view.setInt32(this.offset, value, true);
1436
- this.offset += 4;
1437
- }
1438
- writeFloat(value) {
1439
- this.ensureSpace(4);
1440
- this.view.setFloat32(this.offset, value, true);
1441
- this.offset += 4;
1442
- }
1443
- writeString(value) {
1444
- const len = value.length;
1445
- this.ensureSpace(len + 1);
1446
- for (let i = 0; i < len; i++) {
1447
- this.view.setUint8(this.offset + i, value.charCodeAt(i));
1448
- }
1449
- this.view.setUint8(this.offset + len, 0);
1450
- this.offset += len + 1;
1451
- }
1452
- writeCoord(value) {
1453
- this.writeShort(Math.trunc(value * 8));
1454
- }
1455
- writeAngle(value) {
1456
- this.writeByte(Math.trunc(value * 256 / 360) & 255);
1457
- }
1458
- writeAngle16(value) {
1459
- this.writeShort(Math.trunc(value * 65536 / 360) & 65535);
1460
- }
1461
- writePos(pos) {
1462
- this.writeCoord(pos.x);
1463
- this.writeCoord(pos.y);
1464
- this.writeCoord(pos.z);
1465
- }
1466
- writeDir(dir) {
1467
- let maxDot = -1;
1468
- let bestIndex = 0;
1469
- if (dir.x === 0 && dir.y === 0 && dir.z === 0) {
1470
- this.writeByte(0);
1471
- return;
1472
- }
1473
- for (let i = 0; i < ANORMS.length; i++) {
1474
- const norm = ANORMS[i];
1475
- const dot = dir.x * norm[0] + dir.y * norm[1] + dir.z * norm[2];
1476
- if (dot > maxDot) {
1477
- maxDot = dot;
1478
- bestIndex = i;
1479
- }
1480
- }
1481
- this.writeByte(bestIndex);
1482
- }
1483
- getData() {
1484
- return this.buffer.slice(0, this.offset);
1485
- }
1486
- getBuffer() {
1487
- return this.buffer;
1488
- }
1489
- getOffset() {
1490
- return this.offset;
1491
- }
1492
- reset() {
1493
- this.offset = 0;
1494
- }
1495
- };
1496
- var NetworkMessageBuilder = class {
1497
- constructor(initialSize = 1024) {
1498
- this.buffer = new Uint8Array(initialSize);
1499
- this.view = new DataView(this.buffer.buffer);
1500
- this.offset = 0;
1501
- }
1502
- ensureCapacity(needed) {
1503
- if (this.offset + needed > this.buffer.length) {
1504
- const newSize = Math.max(this.buffer.length * 2, this.offset + needed);
1505
- const newBuffer = new Uint8Array(newSize);
1506
- newBuffer.set(this.buffer);
1507
- this.buffer = newBuffer;
1508
- this.view = new DataView(this.buffer.buffer);
1509
- }
1510
- }
1511
- getData() {
1512
- return this.buffer.slice(0, this.offset);
1513
- }
1514
- writeByte(value) {
1515
- this.ensureCapacity(1);
1516
- this.view.setUint8(this.offset, value);
1517
- this.offset += 1;
1518
- }
1519
- writeChar(value) {
1520
- this.ensureCapacity(1);
1521
- this.view.setInt8(this.offset, value);
1522
- this.offset += 1;
1523
- }
1524
- writeShort(value) {
1525
- this.ensureCapacity(2);
1526
- this.view.setInt16(this.offset, value, true);
1527
- this.offset += 2;
1528
- }
1529
- writeUShort(value) {
1530
- this.ensureCapacity(2);
1531
- this.view.setUint16(this.offset, value, true);
1532
- this.offset += 2;
1533
- }
1534
- writeLong(value) {
1535
- this.ensureCapacity(4);
1536
- this.view.setInt32(this.offset, value, true);
1537
- this.offset += 4;
1538
- }
1539
- writeFloat(value) {
1540
- this.ensureCapacity(4);
1541
- this.view.setFloat32(this.offset, value, true);
1542
- this.offset += 4;
1543
- }
1544
- writeString(value) {
1545
- const len = value.length + 1;
1546
- this.ensureCapacity(len);
1547
- for (let i = 0; i < value.length; i++) {
1548
- this.view.setUint8(this.offset + i, value.charCodeAt(i));
1549
- }
1550
- this.view.setUint8(this.offset + value.length, 0);
1551
- this.offset += len;
1552
- }
1553
- writeData(data) {
1554
- this.ensureCapacity(data.length);
1555
- this.buffer.set(data, this.offset);
1556
- this.offset += data.length;
1557
- }
1558
- writeCoord(value) {
1559
- this.writeShort(Math.round(value * 8));
1560
- }
1561
- writeAngle(value) {
1562
- this.writeByte(Math.round(value * 256 / 360) & 255);
1563
- }
1564
- writeAngle16(value) {
1565
- this.writeShort(Math.round(value * 65536 / 360));
1566
- }
1567
- writeDir(x, y, z) {
1568
- let best = 0;
1569
- let bestDot = -999999;
1570
- const len = Math.sqrt(x * x + y * y + z * z);
1571
- if (len > 0) {
1572
- x /= len;
1573
- y /= len;
1574
- z /= len;
1575
- for (let i = 0; i < 162; i++) {
1576
- const dot = x * ANORMS[i][0] + y * ANORMS[i][1] + z * ANORMS[i][2];
1577
- if (dot > bestDot) {
1578
- bestDot = dot;
1579
- best = i;
1580
- }
1581
- }
1582
- }
1583
- this.writeByte(best);
1584
- }
1585
- };
1586
- var _NetChan = class _NetChan2 {
1587
- constructor() {
1588
- this.qport = 0;
1589
- this.incomingSequence = 0;
1590
- this.outgoingSequence = 0;
1591
- this.incomingAcknowledged = 0;
1592
- this.incomingReliableAcknowledged = false;
1593
- this.incomingReliableSequence = 0;
1594
- this.outgoingReliableSequence = 0;
1595
- this.reliableLength = 0;
1596
- this.fragmentSendOffset = 0;
1597
- this.fragmentBuffer = null;
1598
- this.fragmentLength = 0;
1599
- this.fragmentReceived = 0;
1600
- this.lastReceived = 0;
1601
- this.lastSent = 0;
1602
- this.remoteAddress = null;
1603
- this.reliableMessage = new BinaryWriter(_NetChan2.MAX_RELIABLE_BUFFER);
1604
- const now = Date.now();
1605
- this.lastReceived = now;
1606
- this.lastSent = now;
1607
- this.qport = Math.floor(Math.random() * 65536);
1608
- }
1609
- /**
1610
- * Setup the netchan with specific settings
1611
- */
1612
- setup(qport, address = null) {
1613
- this.qport = qport;
1614
- this.remoteAddress = address;
1615
- this.reset();
1616
- }
1617
- /**
1618
- * Reset the netchan state
1619
- */
1620
- reset() {
1621
- this.incomingSequence = 0;
1622
- this.outgoingSequence = 0;
1623
- this.incomingAcknowledged = 0;
1624
- this.incomingReliableAcknowledged = false;
1625
- this.incomingReliableSequence = 0;
1626
- this.outgoingReliableSequence = 0;
1627
- this.reliableLength = 0;
1628
- this.reliableMessage.reset();
1629
- this.fragmentSendOffset = 0;
1630
- this.fragmentBuffer = null;
1631
- this.fragmentLength = 0;
1632
- this.fragmentReceived = 0;
1633
- this.lastReceived = Date.now();
1634
- this.lastSent = Date.now();
1635
- }
1636
- /**
1637
- * Transmits a packet containing reliable and unreliable data
1638
- */
1639
- transmit(unreliableData) {
1640
- this.outgoingSequence++;
1641
- this.lastSent = Date.now();
1642
- let sendReliableLength = 0;
1643
- let isFragment = false;
1644
- let fragmentStart = 0;
1645
- if (this.reliableLength > 0) {
1646
- if (this.reliableLength > _NetChan2.FRAGMENT_SIZE) {
1647
- isFragment = true;
1648
- if (this.fragmentSendOffset >= this.reliableLength) {
1649
- this.fragmentSendOffset = 0;
1650
- }
1651
- const remaining = this.reliableLength - this.fragmentSendOffset;
1652
- sendReliableLength = remaining;
1653
- if (sendReliableLength > _NetChan2.FRAGMENT_SIZE) {
1654
- sendReliableLength = _NetChan2.FRAGMENT_SIZE;
1655
- }
1656
- fragmentStart = this.fragmentSendOffset;
1657
- this.fragmentSendOffset += sendReliableLength;
1658
- } else {
1659
- sendReliableLength = this.reliableLength;
1660
- }
1661
- }
1662
- const headerSize = _NetChan2.PACKET_HEADER;
1663
- const reliableHeaderSize = sendReliableLength > 0 ? 2 + (isFragment ? 8 : 0) : 0;
1664
- let unreliableSize = unreliableData ? unreliableData.length : 0;
1665
- if (headerSize + reliableHeaderSize + sendReliableLength + unreliableSize > _NetChan2.MAX_MSGLEN) {
1666
- unreliableSize = _NetChan2.MAX_MSGLEN - headerSize - reliableHeaderSize - sendReliableLength;
1667
- if (unreliableSize < 0) unreliableSize = 0;
1668
- }
1669
- const buffer = new ArrayBuffer(headerSize + reliableHeaderSize + sendReliableLength + unreliableSize);
1670
- const view = new DataView(buffer);
1671
- const result = new Uint8Array(buffer);
1672
- let sequence = this.outgoingSequence;
1673
- if (sendReliableLength > 0) {
1674
- sequence |= 2147483648;
1675
- if ((this.outgoingReliableSequence & 1) !== 0) {
1676
- sequence |= 1073741824;
1677
- }
1678
- }
1679
- view.setUint32(0, sequence, true);
1680
- let ack = this.incomingSequence;
1681
- if ((this.incomingReliableSequence & 1) !== 0) {
1682
- ack |= 2147483648;
1683
- }
1684
- view.setUint32(4, ack, true);
1685
- view.setUint16(8, this.qport, true);
1686
- let offset = headerSize;
1687
- if (sendReliableLength > 0) {
1688
- let lengthField = sendReliableLength;
1689
- if (isFragment) {
1690
- lengthField |= 32768;
1691
- }
1692
- view.setUint16(offset, lengthField, true);
1693
- offset += 2;
1694
- if (isFragment) {
1695
- view.setUint32(offset, fragmentStart, true);
1696
- offset += 4;
1697
- view.setUint32(offset, this.reliableLength, true);
1698
- offset += 4;
1699
- }
1700
- const reliableBuffer = this.reliableMessage.getBuffer();
1701
- const reliableBytes = reliableBuffer.subarray(fragmentStart, fragmentStart + sendReliableLength);
1702
- result.set(reliableBytes, offset);
1703
- offset += sendReliableLength;
1704
- }
1705
- if (unreliableData && unreliableSize > 0) {
1706
- const chunk = unreliableData.slice(0, unreliableSize);
1707
- result.set(chunk, offset);
1708
- }
1709
- return result;
1710
- }
1711
- /**
1712
- * Processes a received packet
1713
- * Returns the payload data (reliable + unreliable) to be processed, or null if discarded
1714
- */
1715
- process(packet) {
1716
- if (packet.length < _NetChan2.PACKET_HEADER) {
1717
- return null;
1718
- }
1719
- this.lastReceived = Date.now();
1720
- const view = new DataView(packet.buffer, packet.byteOffset, packet.byteLength);
1721
- const sequence = view.getUint32(0, true);
1722
- const ack = view.getUint32(4, true);
1723
- const qport = view.getUint16(8, true);
1724
- if (this.qport !== qport) {
1725
- return null;
1726
- }
1727
- const seqNumberClean = sequence & ~(2147483648 | 1073741824);
1728
- if ((seqNumberClean - this.incomingSequence | 0) <= 0) {
1729
- return null;
1730
- }
1731
- this.incomingSequence = seqNumberClean;
1732
- const ackNumber = ack & ~2147483648;
1733
- const ackReliable = (ack & 2147483648) !== 0;
1734
- if (ackNumber > this.incomingAcknowledged) {
1735
- this.incomingAcknowledged = ackNumber;
1736
- }
1737
- if (this.reliableLength > 0) {
1738
- const receivedAckBit = ackReliable ? 1 : 0;
1739
- const currentReliableBit = this.outgoingReliableSequence & 1;
1740
- if (receivedAckBit !== currentReliableBit) {
1741
- this.reliableLength = 0;
1742
- this.reliableMessage.reset();
1743
- this.outgoingReliableSequence ^= 1;
1744
- this.fragmentSendOffset = 0;
1745
- }
1746
- }
1747
- const hasReliableData = (sequence & 2147483648) !== 0;
1748
- const reliableSeqBit = (sequence & 1073741824) !== 0 ? 1 : 0;
1749
- let payloadOffset = _NetChan2.PACKET_HEADER;
1750
- let reliableData = null;
1751
- if (hasReliableData) {
1752
- if (payloadOffset + 2 > packet.byteLength) return null;
1753
- let reliableLen = view.getUint16(payloadOffset, true);
1754
- payloadOffset += 2;
1755
- const isFragment = (reliableLen & 32768) !== 0;
1756
- reliableLen &= 32767;
1757
- const expectedBit = this.incomingReliableSequence & 1;
1758
- if (reliableSeqBit === expectedBit) {
1759
- if (isFragment) {
1760
- if (payloadOffset + 8 > packet.byteLength) return null;
1761
- const fragStart = view.getUint32(payloadOffset, true);
1762
- payloadOffset += 4;
1763
- const fragTotal = view.getUint32(payloadOffset, true);
1764
- payloadOffset += 4;
1765
- if (fragTotal > _NetChan2.MAX_RELIABLE_BUFFER) {
1766
- console.warn(`NetChan: received invalid fragment total ${fragTotal} > ${_NetChan2.MAX_RELIABLE_BUFFER}`);
1767
- return null;
1768
- }
1769
- if (!this.fragmentBuffer || this.fragmentBuffer.length !== fragTotal) {
1770
- this.fragmentBuffer = new Uint8Array(fragTotal);
1771
- this.fragmentLength = fragTotal;
1772
- this.fragmentReceived = 0;
1773
- }
1774
- if (payloadOffset + reliableLen > packet.byteLength) return null;
1775
- const data = packet.subarray(payloadOffset, payloadOffset + reliableLen);
1776
- if (fragStart === this.fragmentReceived && fragStart + reliableLen <= fragTotal) {
1777
- this.fragmentBuffer.set(data, fragStart);
1778
- this.fragmentReceived += reliableLen;
1779
- if (this.fragmentReceived >= fragTotal) {
1780
- reliableData = this.fragmentBuffer;
1781
- this.incomingReliableSequence++;
1782
- this.fragmentBuffer = null;
1783
- this.fragmentLength = 0;
1784
- this.fragmentReceived = 0;
1785
- }
1786
- }
1787
- } else {
1788
- this.incomingReliableSequence++;
1789
- if (payloadOffset + reliableLen > packet.byteLength) return null;
1790
- reliableData = packet.slice(payloadOffset, payloadOffset + reliableLen);
1791
- }
1792
- }
1793
- payloadOffset += reliableLen;
1794
- }
1795
- const unreliableData = packet.slice(payloadOffset);
1796
- if (reliableData && reliableData.length > 0) {
1797
- const totalLen = reliableData.length + unreliableData.length;
1798
- const result = new Uint8Array(totalLen);
1799
- result.set(reliableData, 0);
1800
- result.set(unreliableData, reliableData.length);
1801
- return result;
1802
- }
1803
- if (unreliableData) {
1804
- return unreliableData;
1805
- }
1806
- return new Uint8Array(0);
1807
- }
1808
- /**
1809
- * Checks if reliable message buffer is empty and ready for new data
1810
- */
1811
- canSendReliable() {
1812
- return this.reliableLength === 0;
1813
- }
1814
- /**
1815
- * Writes a byte to the reliable message buffer
1816
- */
1817
- writeReliableByte(value) {
1818
- if (this.reliableLength + 1 > _NetChan2.MAX_RELIABLE_BUFFER) {
1819
- throw new Error("NetChan reliable buffer overflow");
1820
- }
1821
- this.reliableMessage.writeByte(value);
1822
- this.reliableLength++;
1823
- }
1824
- /**
1825
- * Writes a short to the reliable message buffer
1826
- */
1827
- writeReliableShort(value) {
1828
- if (this.reliableLength + 2 > _NetChan2.MAX_RELIABLE_BUFFER) {
1829
- throw new Error("NetChan reliable buffer overflow");
1830
- }
1831
- this.reliableMessage.writeShort(value);
1832
- this.reliableLength += 2;
1833
- }
1834
- /**
1835
- * Writes a long to the reliable message buffer
1836
- */
1837
- writeReliableLong(value) {
1838
- if (this.reliableLength + 4 > _NetChan2.MAX_RELIABLE_BUFFER) {
1839
- throw new Error("NetChan reliable buffer overflow");
1840
- }
1841
- this.reliableMessage.writeLong(value);
1842
- this.reliableLength += 4;
1843
- }
1844
- /**
1845
- * Writes a string to the reliable message buffer
1846
- */
1847
- writeReliableString(value) {
1848
- const len = value.length + 1;
1849
- if (this.reliableLength + len > _NetChan2.MAX_RELIABLE_BUFFER) {
1850
- throw new Error("NetChan reliable buffer overflow");
1851
- }
1852
- this.reliableMessage.writeString(value);
1853
- this.reliableLength += len;
1854
- }
1855
- /**
1856
- * Returns the current reliable data buffer
1857
- */
1858
- getReliableData() {
1859
- if (this.reliableLength === 0) {
1860
- return new Uint8Array(0);
1861
- }
1862
- const buffer = this.reliableMessage.getBuffer();
1863
- return buffer.subarray(0, this.reliableLength);
1864
- }
1865
- /**
1866
- * Checks if we need to send a keepalive packet
1867
- */
1868
- needsKeepalive(currentTime) {
1869
- return currentTime - this.lastSent > 1e3;
1870
- }
1871
- /**
1872
- * Checks if the connection has timed out
1873
- */
1874
- isTimedOut(currentTime, timeoutMs = 3e4) {
1875
- return currentTime - this.lastReceived > timeoutMs;
1876
- }
1877
- };
1878
- _NetChan.MAX_MSGLEN = 1400;
1879
- _NetChan.FRAGMENT_SIZE = 1024;
1880
- _NetChan.PACKET_HEADER = 10;
1881
- _NetChan.HEADER_OVERHEAD = _NetChan.PACKET_HEADER + 2;
1882
- _NetChan.MAX_RELIABLE_BUFFER = 262144;
1883
- var NetChan = _NetChan;
1884
- var AmmoType = /* @__PURE__ */ ((AmmoType2) => {
1885
- AmmoType2[AmmoType2["Bullets"] = 0] = "Bullets";
1886
- AmmoType2[AmmoType2["Shells"] = 1] = "Shells";
1887
- AmmoType2[AmmoType2["Rockets"] = 2] = "Rockets";
1888
- AmmoType2[AmmoType2["Grenades"] = 3] = "Grenades";
1889
- AmmoType2[AmmoType2["Cells"] = 4] = "Cells";
1890
- AmmoType2[AmmoType2["Slugs"] = 5] = "Slugs";
1891
- AmmoType2[AmmoType2["MagSlugs"] = 6] = "MagSlugs";
1892
- AmmoType2[AmmoType2["Trap"] = 7] = "Trap";
1893
- AmmoType2[AmmoType2["Flechettes"] = 8] = "Flechettes";
1894
- AmmoType2[AmmoType2["Tesla"] = 9] = "Tesla";
1895
- AmmoType2[AmmoType2["Disruptor"] = 10] = "Disruptor";
1896
- AmmoType2[AmmoType2["Prox"] = 11] = "Prox";
1897
- AmmoType2[AmmoType2["Nuke"] = 12] = "Nuke";
1898
- AmmoType2[AmmoType2["Rounds"] = 13] = "Rounds";
1899
- return AmmoType2;
1900
- })(AmmoType || {});
1901
- var AMMO_TYPE_COUNT = Object.keys(AmmoType).length / 2;
1902
- var MAX_SOUND_CHANNELS = 32;
1903
- var SoundChannel = /* @__PURE__ */ ((SoundChannel2) => {
1904
- SoundChannel2[SoundChannel2["Auto"] = 0] = "Auto";
1905
- SoundChannel2[SoundChannel2["Weapon"] = 1] = "Weapon";
1906
- SoundChannel2[SoundChannel2["Voice"] = 2] = "Voice";
1907
- SoundChannel2[SoundChannel2["Item"] = 3] = "Item";
1908
- SoundChannel2[SoundChannel2["Body"] = 4] = "Body";
1909
- SoundChannel2[SoundChannel2["Aux"] = 5] = "Aux";
1910
- SoundChannel2[SoundChannel2["Footstep"] = 6] = "Footstep";
1911
- SoundChannel2[SoundChannel2["Aux3"] = 7] = "Aux3";
1912
- SoundChannel2[SoundChannel2["NoPhsAdd"] = 8] = "NoPhsAdd";
1913
- SoundChannel2[SoundChannel2["Reliable"] = 16] = "Reliable";
1914
- SoundChannel2[SoundChannel2["ForcePos"] = 32] = "ForcePos";
1915
- return SoundChannel2;
1916
- })(SoundChannel || {});
1917
- var ATTN_LOOP_NONE = -1;
1918
- var ATTN_NONE = 0;
1919
- var ATTN_NORM = 1;
1920
- var ATTN_IDLE = 2;
1921
- var ATTN_STATIC = 3;
1922
- var SOUND_FULLVOLUME = 80;
1923
- var SOUND_LOOP_ATTENUATE = 3e-3;
1924
- function attenuationToDistanceMultiplier(attenuation) {
1925
- return attenuation * 1e-3;
1926
- }
1927
- function calculateMaxAudibleDistance(attenuation) {
1928
- const distMult = attenuationToDistanceMultiplier(attenuation);
1929
- return distMult <= 0 ? Number.POSITIVE_INFINITY : SOUND_FULLVOLUME + 1 / distMult;
1930
- }
1931
-
1932
- // src/cvars.ts
1933
189
  var Cvar = class {
1934
190
  constructor({
1935
191
  name,
1936
192
  defaultValue,
1937
193
  description,
1938
- flags = CvarFlags.None,
194
+ flags = shared.CvarFlags.None,
1939
195
  onChange
1940
196
  }) {
1941
197
  this.modifiedCount = 0;
@@ -1971,7 +227,7 @@ var Cvar = class {
1971
227
  return this.boolean;
1972
228
  }
1973
229
  set(value) {
1974
- if (this.flags & CvarFlags.Latch) {
230
+ if (this.flags & shared.CvarFlags.Latch) {
1975
231
  if (value === this._value) {
1976
232
  this.latched = void 0;
1977
233
  return;
@@ -2278,32 +534,30 @@ function createEngineRuntime(engine, game, client, audioOptions, options) {
2278
534
  const runtime = new EngineRuntime(engine, host);
2279
535
  return { runtime, audio };
2280
536
  }
2281
-
2282
- // src/configstrings.ts
2283
537
  function assertWithinBounds(index) {
2284
- if (index < 0 || index >= ConfigStringIndex.MaxConfigStrings) {
2285
- throw new RangeError(`Configstring index ${index} is out of range (0-${ConfigStringIndex.MaxConfigStrings - 1})`);
538
+ if (index < 0 || index >= shared.ConfigStringIndex.MaxConfigStrings) {
539
+ throw new RangeError(`Configstring index ${index} is out of range (0-${shared.ConfigStringIndex.MaxConfigStrings - 1})`);
2286
540
  }
2287
541
  }
2288
542
  function assertLength(index, value) {
2289
- const maxLength = configStringSize(index);
543
+ const maxLength = shared.configStringSize(index);
2290
544
  if (value.length > maxLength) {
2291
545
  throw new RangeError(
2292
- `Configstring ${index} exceeds maximum length (${value.length} > ${maxLength}); limit is ${CS_MAX_STRING_LENGTH} chars per slot`
546
+ `Configstring ${index} exceeds maximum length (${value.length} > ${maxLength}); limit is ${shared.CS_MAX_STRING_LENGTH} chars per slot`
2293
547
  );
2294
548
  }
2295
549
  }
2296
550
  var ConfigStringRegistry = class {
2297
551
  constructor() {
2298
552
  this.values = /* @__PURE__ */ new Map();
2299
- this.modelCursor = ConfigStringIndex.Models;
2300
- this.soundCursor = ConfigStringIndex.Sounds;
2301
- this.imageCursor = ConfigStringIndex.Images;
2302
- this.lightCursor = ConfigStringIndex.Lights;
2303
- this.shadowLightCursor = ConfigStringIndex.ShadowLights;
2304
- this.itemCursor = ConfigStringIndex.Items;
2305
- this.playerSkinCursor = ConfigStringIndex.PlayerSkins;
2306
- this.generalCursor = ConfigStringIndex.General;
553
+ this.modelCursor = shared.ConfigStringIndex.Models;
554
+ this.soundCursor = shared.ConfigStringIndex.Sounds;
555
+ this.imageCursor = shared.ConfigStringIndex.Images;
556
+ this.lightCursor = shared.ConfigStringIndex.Lights;
557
+ this.shadowLightCursor = shared.ConfigStringIndex.ShadowLights;
558
+ this.itemCursor = shared.ConfigStringIndex.Items;
559
+ this.playerSkinCursor = shared.ConfigStringIndex.PlayerSkins;
560
+ this.generalCursor = shared.ConfigStringIndex.General;
2307
561
  }
2308
562
  set(index, value) {
2309
563
  assertWithinBounds(index);
@@ -2318,20 +572,20 @@ var ConfigStringRegistry = class {
2318
572
  return this.get(index);
2319
573
  }
2320
574
  getAll() {
2321
- const result = new Array(MAX_CONFIGSTRINGS).fill("");
575
+ const result = new Array(shared.MAX_CONFIGSTRINGS).fill("");
2322
576
  for (const [index, value] of this.values.entries()) {
2323
577
  result[index] = value;
2324
578
  }
2325
579
  return result;
2326
580
  }
2327
581
  modelIndex(path) {
2328
- return this.register(path, ConfigStringIndex.Models, MAX_MODELS, "modelCursor");
582
+ return this.register(path, shared.ConfigStringIndex.Models, shared.MAX_MODELS, "modelCursor");
2329
583
  }
2330
584
  soundIndex(path) {
2331
- return this.register(path, ConfigStringIndex.Sounds, MAX_SOUNDS, "soundCursor");
585
+ return this.register(path, shared.ConfigStringIndex.Sounds, shared.MAX_SOUNDS, "soundCursor");
2332
586
  }
2333
587
  findSoundIndex(path) {
2334
- for (let i = ConfigStringIndex.Sounds; i < ConfigStringIndex.Sounds + MAX_SOUNDS; i += 1) {
588
+ for (let i = shared.ConfigStringIndex.Sounds; i < shared.ConfigStringIndex.Sounds + shared.MAX_SOUNDS; i += 1) {
2335
589
  if (this.values.get(i) === path) {
2336
590
  return i;
2337
591
  }
@@ -2339,22 +593,22 @@ var ConfigStringRegistry = class {
2339
593
  return void 0;
2340
594
  }
2341
595
  imageIndex(path) {
2342
- return this.register(path, ConfigStringIndex.Images, MAX_IMAGES, "imageCursor");
596
+ return this.register(path, shared.ConfigStringIndex.Images, shared.MAX_IMAGES, "imageCursor");
2343
597
  }
2344
598
  lightIndex(definition) {
2345
- return this.register(definition, ConfigStringIndex.Lights, MAX_LIGHTSTYLES, "lightCursor");
599
+ return this.register(definition, shared.ConfigStringIndex.Lights, shared.MAX_LIGHTSTYLES, "lightCursor");
2346
600
  }
2347
601
  shadowLightIndex(definition) {
2348
- return this.register(definition, ConfigStringIndex.ShadowLights, MAX_SHADOW_LIGHTS, "shadowLightCursor");
602
+ return this.register(definition, shared.ConfigStringIndex.ShadowLights, shared.MAX_SHADOW_LIGHTS, "shadowLightCursor");
2349
603
  }
2350
604
  itemIndex(name) {
2351
- return this.register(name, ConfigStringIndex.Items, MAX_ITEMS, "itemCursor");
605
+ return this.register(name, shared.ConfigStringIndex.Items, shared.MAX_ITEMS, "itemCursor");
2352
606
  }
2353
607
  playerSkinIndex(name) {
2354
- return this.register(name, ConfigStringIndex.PlayerSkins, MAX_CLIENTS, "playerSkinCursor");
608
+ return this.register(name, shared.ConfigStringIndex.PlayerSkins, shared.MAX_CLIENTS, "playerSkinCursor");
2355
609
  }
2356
610
  generalIndex(value) {
2357
- return this.register(value, ConfigStringIndex.General, MAX_GENERAL, "generalCursor");
611
+ return this.register(value, shared.ConfigStringIndex.General, shared.MAX_GENERAL, "generalCursor");
2358
612
  }
2359
613
  register(value, start, maxCount, cursorKey) {
2360
614
  for (let i = start; i < start + maxCount; i += 1) {
@@ -2550,8 +804,7 @@ var StreamingPakArchive = class {
2550
804
  const normalized = normalizePath2(rawName);
2551
805
  const fileOffset = dirView.getInt32(offset + 56, true);
2552
806
  const fileLength = dirView.getInt32(offset + 60, true);
2553
- if (fileOffset < 0 || fileLength < 0 || fileOffset + fileLength > this.source.size) {
2554
- }
807
+ if (fileOffset < 0 || fileLength < 0 || fileOffset + fileLength > this.source.size) ;
2555
808
  if (normalized) {
2556
809
  entries.set(normalized, { name: normalized, offset: fileOffset, length: fileLength });
2557
810
  }
@@ -2968,11 +1221,10 @@ var VirtualFileSystem = class {
2968
1221
  }).sort((a, b) => a.path.localeCompare(b.path));
2969
1222
  for (const file of allFiles) {
2970
1223
  const parts = file.path.split("/");
2971
- const fileName = parts.pop();
1224
+ parts.pop();
2972
1225
  let currentPath = "";
2973
1226
  let currentNode = root;
2974
1227
  for (const part of parts) {
2975
- const parentPath = currentPath;
2976
1228
  currentPath = currentPath ? `${currentPath}/${part}` : part;
2977
1229
  let nextNode = nodeMap.get(currentPath);
2978
1230
  if (!nextNode) {
@@ -3920,8 +2172,6 @@ function createFaceLightmap(face, lightMaps, info) {
3920
2172
  }
3921
2173
  return lightMaps.subarray(face.lightOffset, face.lightOffset + length);
3922
2174
  }
3923
-
3924
- // src/assets/md2.ts
3925
2175
  var MD2_MAGIC = 844121161;
3926
2176
  var MD2_VERSION = 8;
3927
2177
  var HEADER_SIZE5 = 68;
@@ -4079,7 +2329,7 @@ function parseFrames(buffer, header) {
4079
2329
  if (z > maxZ) maxZ = z;
4080
2330
  const position = { x, y, z };
4081
2331
  const normalIndex = view.getUint8(offset + 3);
4082
- const normalArr = ANORMS[normalIndex];
2332
+ const normalArr = shared.ANORMS[normalIndex];
4083
2333
  if (!normalArr) {
4084
2334
  throw new Md2ParseError(`Invalid normal index ${normalIndex} in frame ${name}`);
4085
2335
  }
@@ -4657,7 +2907,6 @@ function parseTga(buffer) {
4657
2907
  const pixelCount = width * height;
4658
2908
  const pixels = new Uint8Array(pixelCount * 4);
4659
2909
  const originTopLeft = (imageDescriptor & 32) !== 0;
4660
- let currentPixel = 0;
4661
2910
  const rawData = new Uint8Array(buffer);
4662
2911
  const readPixel = (outIndex) => {
4663
2912
  if (isGrayscale) {
@@ -4833,7 +3082,6 @@ function parseWav(buffer) {
4833
3082
  let offset = 12;
4834
3083
  let fmtOffset = -1;
4835
3084
  let dataOffset = -1;
4836
- let fmtSize = 0;
4837
3085
  let dataSize = 0;
4838
3086
  while (offset + 8 <= buffer.byteLength) {
4839
3087
  const chunkId = readString2(view, offset, 4);
@@ -4841,7 +3089,6 @@ function parseWav(buffer) {
4841
3089
  const chunkDataOffset = offset + 8;
4842
3090
  if (chunkId === "fmt ") {
4843
3091
  fmtOffset = chunkDataOffset;
4844
- fmtSize = chunkSize;
4845
3092
  } else if (chunkId === "data") {
4846
3093
  dataOffset = chunkDataOffset;
4847
3094
  dataSize = chunkSize;
@@ -4885,16 +3132,13 @@ function parseWav(buffer) {
4885
3132
  }
4886
3133
  return { sampleRate, channels, bitsPerSample, samples };
4887
3134
  }
4888
-
4889
- // src/assets/ogg.ts
4890
- var import_ogg_vorbis = require("@wasm-audio-decoders/ogg-vorbis");
4891
3135
  var OggDecodeError = class extends Error {
4892
3136
  constructor(message) {
4893
3137
  super(message);
4894
3138
  this.name = "OggDecodeError";
4895
3139
  }
4896
3140
  };
4897
- async function decodeOgg(buffer, decoder = new import_ogg_vorbis.OggVorbisDecoder()) {
3141
+ async function decodeOgg(buffer, decoder = new oggVorbis.OggVorbisDecoder()) {
4898
3142
  await decoder.ready;
4899
3143
  const result = await decoder.decode(new Uint8Array(buffer));
4900
3144
  const errors = result.errors;
@@ -5641,9 +3885,9 @@ var SoundPrecache = class {
5641
3885
  var CHANNEL_MASK = 7;
5642
3886
  var baseChannel = (entchannel) => entchannel & CHANNEL_MASK;
5643
3887
  function createInitialChannels(playerEntity) {
5644
- return Array.from({ length: MAX_SOUND_CHANNELS }, () => ({
3888
+ return Array.from({ length: shared.MAX_SOUND_CHANNELS }, () => ({
5645
3889
  entnum: 0,
5646
- entchannel: SoundChannel.Auto,
3890
+ entchannel: shared.SoundChannel.Auto,
5647
3891
  endTimeMs: 0,
5648
3892
  isPlayer: false,
5649
3893
  active: false
@@ -5659,7 +3903,7 @@ function pickChannel(channels, entnum, entchannel, context) {
5659
3903
  for (let i = 0; i < channels.length; i += 1) {
5660
3904
  const channel = channels[i];
5661
3905
  const channelBase = baseChannel(channel.entchannel);
5662
- if (normalizedEntchannel !== SoundChannel.Auto && channel.entnum === entnum && channelBase === normalizedEntchannel) {
3906
+ if (normalizedEntchannel !== shared.SoundChannel.Auto && channel.entnum === entnum && channelBase === normalizedEntchannel) {
5663
3907
  firstToDie = i;
5664
3908
  break;
5665
3909
  }
@@ -5720,7 +3964,7 @@ var AudioSystem = class {
5720
3964
  this.registry = options.registry;
5721
3965
  this.playerEntity = options.playerEntity;
5722
3966
  this.channels = createInitialChannels(options.playerEntity);
5723
- this.listener = options.listener ?? { origin: ZERO_VEC3, right: { x: 1, y: 0, z: 0 } };
3967
+ this.listener = options.listener ?? { origin: shared.ZERO_VEC3, right: { x: 1, y: 0, z: 0 } };
5724
3968
  this.sfxVolume = options.sfxVolume ?? 1;
5725
3969
  this.masterVolume = options.masterVolume ?? 1;
5726
3970
  this.resolveOcclusion = options.resolveOcclusion;
@@ -5791,14 +4035,11 @@ var AudioSystem = class {
5791
4035
  const startTimeSec = ctx.currentTime + (request.timeOffsetMs ?? 0) / 1e3;
5792
4036
  const endTimeMs = (request.looping ? Number.POSITIVE_INFINITY : buffer.duration * 1e3) + startTimeSec * 1e3;
5793
4037
  source.connect(panner);
5794
- let finalNode = panner;
5795
4038
  if (occlusionFilter) {
5796
4039
  panner.connect(occlusionFilter);
5797
4040
  occlusionFilter.connect(gain);
5798
- finalNode = gain;
5799
4041
  } else {
5800
4042
  panner.connect(gain);
5801
- finalNode = gain;
5802
4043
  }
5803
4044
  gain.connect(this.graph.master);
5804
4045
  if (this.reverb) {
@@ -5861,7 +4102,7 @@ var AudioSystem = class {
5861
4102
  positionedSound(origin, soundIndex, volume, attenuation) {
5862
4103
  return this.play({
5863
4104
  entity: 0,
5864
- channel: SoundChannel.Auto,
4105
+ channel: shared.SoundChannel.Auto,
5865
4106
  soundIndex,
5866
4107
  volume,
5867
4108
  attenuation,
@@ -5871,10 +4112,10 @@ var AudioSystem = class {
5871
4112
  ambientSound(origin, soundIndex, volume) {
5872
4113
  return this.play({
5873
4114
  entity: 0,
5874
- channel: SoundChannel.Auto,
4115
+ channel: shared.SoundChannel.Auto,
5875
4116
  soundIndex,
5876
4117
  volume,
5877
- attenuation: ATTN_NONE,
4118
+ attenuation: shared.ATTN_NONE,
5878
4119
  origin,
5879
4120
  looping: true
5880
4121
  });
@@ -5918,9 +4159,9 @@ var AudioSystem = class {
5918
4159
  return this.configurePanner(panner, attenuation);
5919
4160
  }
5920
4161
  configurePanner(panner, attenuation) {
5921
- const distMult = attenuationToDistanceMultiplier(attenuation);
5922
- panner.refDistance = SOUND_FULLVOLUME;
5923
- panner.maxDistance = calculateMaxAudibleDistance(attenuation);
4162
+ const distMult = shared.attenuationToDistanceMultiplier(attenuation);
4163
+ panner.refDistance = shared.SOUND_FULLVOLUME;
4164
+ panner.maxDistance = shared.calculateMaxAudibleDistance(attenuation);
5924
4165
  panner.rolloffFactor = distMult;
5925
4166
  panner.distanceModel = "linear";
5926
4167
  panner.positionX.value = this.listener.origin.x;
@@ -5964,14 +4205,12 @@ var AudioSystem = class {
5964
4205
  };
5965
4206
  var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
5966
4207
  var clamp01 = (value) => clamp(value, 0, 1);
5967
-
5968
- // src/audio/occlusion.ts
5969
4208
  var AudioOcclusion = class {
5970
4209
  constructor(trace) {
5971
4210
  this.trace = trace;
5972
4211
  this.resolve = (listener, source, attenuation) => {
5973
- const dist = lengthVec3(subtractVec3(source, listener.origin));
5974
- const maxDist = calculateMaxAudibleDistance(attenuation);
4212
+ const dist = shared.lengthVec3(shared.subtractVec3(source, listener.origin));
4213
+ const maxDist = shared.calculateMaxAudibleDistance(attenuation);
5975
4214
  const clampedDist = Math.min(dist, maxDist);
5976
4215
  const distanceFactor = clampedDist / Math.max(1, maxDist);
5977
4216
  const distanceCutoff = 2e4 * (1 - distanceFactor * 0.9);
@@ -6048,8 +4287,7 @@ var MusicSystem = class {
6048
4287
  await element.play();
6049
4288
  } catch (e) {
6050
4289
  console.warn(`MusicSystem: Failed to play ${track}`, e);
6051
- if (this.fadingElement) {
6052
- }
4290
+ if (this.fadingElement) ;
6053
4291
  }
6054
4292
  this.currentElement = element;
6055
4293
  this.track = track;
@@ -6461,8 +4699,6 @@ var Framebuffer = class {
6461
4699
  this.gl.deleteFramebuffer(this.framebuffer);
6462
4700
  }
6463
4701
  };
6464
-
6465
- // src/render/bsp.ts
6466
4702
  var FLOAT_BYTES = 4;
6467
4703
  var STRIDE = 7 * FLOAT_BYTES;
6468
4704
  var BSP_VERTEX_LAYOUT = [
@@ -6732,7 +4968,7 @@ function buildBspGeometry(gl, surfaces, map, options = {}) {
6732
4968
  indexCount: indexData.length,
6733
4969
  vertexCount: vertexData.length / 7,
6734
4970
  texture: surface.texture,
6735
- surfaceFlags: surface.surfaceFlags ?? SURF_NONE,
4971
+ surfaceFlags: surface.surfaceFlags ?? shared.SURF_NONE,
6736
4972
  lightmap: placement,
6737
4973
  vertexData,
6738
4974
  indexData
@@ -7229,12 +5465,12 @@ function computeFlowOffset(timeSeconds) {
7229
5465
  const cycle = timeSeconds * 0.25 % 1;
7230
5466
  return [-cycle, 0];
7231
5467
  }
7232
- function deriveSurfaceRenderState(surfaceFlags = SURF_NONE, timeSeconds = 0) {
7233
- const flowing = (surfaceFlags & SURF_FLOWING) !== 0;
7234
- const warp = (surfaceFlags & SURF_WARP) !== 0;
7235
- const sky = (surfaceFlags & SURF_SKY) !== 0;
7236
- const trans33 = (surfaceFlags & SURF_TRANS33) !== 0;
7237
- const trans66 = (surfaceFlags & SURF_TRANS66) !== 0;
5468
+ function deriveSurfaceRenderState(surfaceFlags = shared.SURF_NONE, timeSeconds = 0) {
5469
+ const flowing = (surfaceFlags & shared.SURF_FLOWING) !== 0;
5470
+ const warp = (surfaceFlags & shared.SURF_WARP) !== 0;
5471
+ const sky = (surfaceFlags & shared.SURF_SKY) !== 0;
5472
+ const trans33 = (surfaceFlags & shared.SURF_TRANS33) !== 0;
5473
+ const trans66 = (surfaceFlags & shared.SURF_TRANS66) !== 0;
7238
5474
  const alpha = trans33 ? 0.33 : trans66 ? 0.66 : 1;
7239
5475
  const blend = trans33 || trans66 || warp;
7240
5476
  const depthWrite = !blend && !sky;
@@ -7298,7 +5534,7 @@ var BspSurfacePipeline = class {
7298
5534
  diffuseSampler = 0,
7299
5535
  lightmapSampler,
7300
5536
  refractionSampler,
7301
- surfaceFlags = SURF_NONE,
5537
+ surfaceFlags = shared.SURF_NONE,
7302
5538
  timeSeconds = 0,
7303
5539
  texScroll,
7304
5540
  alpha,
@@ -7716,7 +5952,7 @@ void main() {
7716
5952
 
7717
5953
  o_color = finalColor;
7718
5954
  }`;
7719
- function normalizeVec32(v) {
5955
+ function normalizeVec3(v) {
7720
5956
  const lengthSq = v.x * v.x + v.y * v.y + v.z * v.z;
7721
5957
  if (lengthSq <= 0) {
7722
5958
  return { x: 0, y: 0, z: 1 };
@@ -7797,7 +6033,7 @@ function buildMd2VertexData(model, geometry, blend) {
7797
6033
  throw new Error("MD2 vertex index out of range for frame");
7798
6034
  }
7799
6035
  const position = lerpVec3(vA.position, vB.position, lerp3);
7800
- const normal = normalizeVec32(lerpVec3(vA.normal, vB.normal, lerp3));
6036
+ const normal = normalizeVec3(lerpVec3(vA.normal, vB.normal, lerp3));
7801
6037
  const base = index * 8;
7802
6038
  data[base] = position.x;
7803
6039
  data[base + 1] = position.y;
@@ -7914,8 +6150,7 @@ var Md2Pipeline = class {
7914
6150
  else if (renderMode.mode === "solid-faceted") modeInt = 2;
7915
6151
  if (renderMode.color) {
7916
6152
  color = [...renderMode.color];
7917
- } else if (renderMode.generateRandomColor) {
7918
- }
6153
+ } else if (renderMode.generateRandomColor) ;
7919
6154
  }
7920
6155
  this.gl.uniform1i(this.uniformRenderMode, modeInt);
7921
6156
  this.gl.uniform4f(this.uniformSolidColor, color[0], color[1], color[2], color[3]);
@@ -7952,33 +6187,30 @@ var Md2Pipeline = class {
7952
6187
  this.program.dispose();
7953
6188
  }
7954
6189
  };
7955
-
7956
- // src/render/camera.ts
7957
- var import_gl_matrix = require("gl-matrix");
7958
6190
  var Camera = class {
7959
6191
  constructor() {
7960
- this._position = import_gl_matrix.vec3.create();
7961
- this._angles = import_gl_matrix.vec3.create();
6192
+ this._position = glMatrix.vec3.create();
6193
+ this._angles = glMatrix.vec3.create();
7962
6194
  // pitch, yaw, roll
7963
- this._bobAngles = import_gl_matrix.vec3.create();
7964
- this._bobOffset = import_gl_matrix.vec3.create();
7965
- this._kickAngles = import_gl_matrix.vec3.create();
6195
+ this._bobAngles = glMatrix.vec3.create();
6196
+ this._bobOffset = glMatrix.vec3.create();
6197
+ this._kickAngles = glMatrix.vec3.create();
7966
6198
  this._rollAngle = 0;
7967
6199
  this._fov = 90;
7968
6200
  this._aspect = 1;
7969
6201
  this._near = 0.1;
7970
6202
  this._far = 1e3;
7971
- this._viewMatrix = import_gl_matrix.mat4.create();
7972
- this._projectionMatrix = import_gl_matrix.mat4.create();
7973
- this._viewProjectionMatrix = import_gl_matrix.mat4.create();
6203
+ this._viewMatrix = glMatrix.mat4.create();
6204
+ this._projectionMatrix = glMatrix.mat4.create();
6205
+ this._viewProjectionMatrix = glMatrix.mat4.create();
7974
6206
  this._dirty = true;
7975
6207
  }
7976
6208
  get position() {
7977
6209
  return this._position;
7978
6210
  }
7979
6211
  set position(value) {
7980
- if (!import_gl_matrix.vec3.equals(this._position, value)) {
7981
- import_gl_matrix.vec3.copy(this._position, value);
6212
+ if (!glMatrix.vec3.equals(this._position, value)) {
6213
+ glMatrix.vec3.copy(this._position, value);
7982
6214
  this._dirty = true;
7983
6215
  this.triggerMoveEvent();
7984
6216
  }
@@ -7987,8 +6219,8 @@ var Camera = class {
7987
6219
  return this._angles;
7988
6220
  }
7989
6221
  set angles(value) {
7990
- if (!import_gl_matrix.vec3.equals(this._angles, value)) {
7991
- import_gl_matrix.vec3.copy(this._angles, value);
6222
+ if (!glMatrix.vec3.equals(this._angles, value)) {
6223
+ glMatrix.vec3.copy(this._angles, value);
7992
6224
  this._dirty = true;
7993
6225
  this.triggerMoveEvent();
7994
6226
  }
@@ -7997,21 +6229,21 @@ var Camera = class {
7997
6229
  return this._bobAngles;
7998
6230
  }
7999
6231
  set bobAngles(value) {
8000
- import_gl_matrix.vec3.copy(this._bobAngles, value);
6232
+ glMatrix.vec3.copy(this._bobAngles, value);
8001
6233
  this._dirty = true;
8002
6234
  }
8003
6235
  get kickAngles() {
8004
6236
  return this._kickAngles;
8005
6237
  }
8006
6238
  set kickAngles(value) {
8007
- import_gl_matrix.vec3.copy(this._kickAngles, value);
6239
+ glMatrix.vec3.copy(this._kickAngles, value);
8008
6240
  this._dirty = true;
8009
6241
  }
8010
6242
  get bobOffset() {
8011
6243
  return this._bobOffset;
8012
6244
  }
8013
6245
  set bobOffset(value) {
8014
- import_gl_matrix.vec3.copy(this._bobOffset, value);
6246
+ glMatrix.vec3.copy(this._bobOffset, value);
8015
6247
  this._dirty = true;
8016
6248
  }
8017
6249
  get rollAngle() {
@@ -8037,17 +6269,17 @@ var Camera = class {
8037
6269
  }
8038
6270
  // API Methods
8039
6271
  setPosition(x, y, z) {
8040
- const newPos = import_gl_matrix.vec3.fromValues(x, y, z);
8041
- if (!import_gl_matrix.vec3.equals(this._position, newPos)) {
8042
- import_gl_matrix.vec3.copy(this._position, newPos);
6272
+ const newPos = glMatrix.vec3.fromValues(x, y, z);
6273
+ if (!glMatrix.vec3.equals(this._position, newPos)) {
6274
+ glMatrix.vec3.copy(this._position, newPos);
8043
6275
  this._dirty = true;
8044
6276
  this.triggerMoveEvent();
8045
6277
  }
8046
6278
  }
8047
6279
  setRotation(pitch, yaw, roll) {
8048
- const newAngles = import_gl_matrix.vec3.fromValues(pitch, yaw, roll);
8049
- if (!import_gl_matrix.vec3.equals(this._angles, newAngles)) {
8050
- import_gl_matrix.vec3.copy(this._angles, newAngles);
6280
+ const newAngles = glMatrix.vec3.fromValues(pitch, yaw, roll);
6281
+ if (!glMatrix.vec3.equals(this._angles, newAngles)) {
6282
+ glMatrix.vec3.copy(this._angles, newAngles);
8051
6283
  this._dirty = true;
8052
6284
  this.triggerMoveEvent();
8053
6285
  }
@@ -8059,20 +6291,20 @@ var Camera = class {
8059
6291
  this.aspect = aspect;
8060
6292
  }
8061
6293
  lookAt(target) {
8062
- const direction = import_gl_matrix.vec3.create();
8063
- import_gl_matrix.vec3.subtract(direction, target, this._position);
8064
- const len = import_gl_matrix.vec3.length(direction);
6294
+ const direction = glMatrix.vec3.create();
6295
+ glMatrix.vec3.subtract(direction, target, this._position);
6296
+ const len = glMatrix.vec3.length(direction);
8065
6297
  if (len < 1e-3) return;
8066
- const yaw = Math.atan2(direction[1], direction[0]) * RAD2DEG;
6298
+ const yaw = Math.atan2(direction[1], direction[0]) * shared.RAD2DEG;
8067
6299
  const hyp = Math.hypot(direction[0], direction[1]);
8068
- const pitch = -Math.atan2(direction[2], hyp) * RAD2DEG;
6300
+ const pitch = -Math.atan2(direction[2], hyp) * shared.RAD2DEG;
8069
6301
  this.setRotation(pitch, yaw, 0);
8070
6302
  }
8071
6303
  triggerMoveEvent() {
8072
6304
  if (this.onCameraMove) {
8073
6305
  this.onCameraMove({
8074
- position: import_gl_matrix.vec3.clone(this._position),
8075
- angles: import_gl_matrix.vec3.clone(this._angles)
6306
+ position: glMatrix.vec3.clone(this._position),
6307
+ angles: glMatrix.vec3.clone(this._angles)
8076
6308
  });
8077
6309
  }
8078
6310
  }
@@ -8089,10 +6321,10 @@ var Camera = class {
8089
6321
  return this._viewProjectionMatrix;
8090
6322
  }
8091
6323
  getViewmodelProjectionMatrix(fov) {
8092
- const projectionMatrix = import_gl_matrix.mat4.create();
8093
- import_gl_matrix.mat4.perspective(
6324
+ const projectionMatrix = glMatrix.mat4.create();
6325
+ glMatrix.mat4.perspective(
8094
6326
  projectionMatrix,
8095
- fov * DEG2RAD,
6327
+ fov * shared.DEG2RAD,
8096
6328
  this._aspect,
8097
6329
  this._near,
8098
6330
  this._far
@@ -8102,19 +6334,19 @@ var Camera = class {
8102
6334
  screenToWorldRay(screenX, screenY) {
8103
6335
  const ndcX = screenX * 2 - 1;
8104
6336
  const ndcY = 1 - screenY * 2;
8105
- const clipStart = import_gl_matrix.vec3.fromValues(ndcX, ndcY, -1);
8106
- const clipEnd = import_gl_matrix.vec3.fromValues(ndcX, ndcY, 1);
8107
- const invViewProj = import_gl_matrix.mat4.create();
8108
- import_gl_matrix.mat4.invert(invViewProj, this.viewProjectionMatrix);
8109
- const worldStart = import_gl_matrix.vec3.create();
8110
- const worldEnd = import_gl_matrix.vec3.create();
8111
- import_gl_matrix.vec3.transformMat4(worldStart, clipStart, invViewProj);
8112
- import_gl_matrix.vec3.transformMat4(worldEnd, clipEnd, invViewProj);
8113
- const direction = import_gl_matrix.vec3.create();
8114
- import_gl_matrix.vec3.subtract(direction, worldEnd, worldStart);
8115
- import_gl_matrix.vec3.normalize(direction, direction);
6337
+ const clipStart = glMatrix.vec3.fromValues(ndcX, ndcY, -1);
6338
+ const clipEnd = glMatrix.vec3.fromValues(ndcX, ndcY, 1);
6339
+ const invViewProj = glMatrix.mat4.create();
6340
+ glMatrix.mat4.invert(invViewProj, this.viewProjectionMatrix);
6341
+ const worldStart = glMatrix.vec3.create();
6342
+ const worldEnd = glMatrix.vec3.create();
6343
+ glMatrix.vec3.transformMat4(worldStart, clipStart, invViewProj);
6344
+ glMatrix.vec3.transformMat4(worldEnd, clipEnd, invViewProj);
6345
+ const direction = glMatrix.vec3.create();
6346
+ glMatrix.vec3.subtract(direction, worldEnd, worldStart);
6347
+ glMatrix.vec3.normalize(direction, direction);
8116
6348
  return {
8117
- origin: import_gl_matrix.vec3.clone(this._position),
6349
+ origin: glMatrix.vec3.clone(this._position),
8118
6350
  direction
8119
6351
  };
8120
6352
  }
@@ -8122,14 +6354,14 @@ var Camera = class {
8122
6354
  if (!this._dirty) {
8123
6355
  return;
8124
6356
  }
8125
- import_gl_matrix.mat4.perspective(
6357
+ glMatrix.mat4.perspective(
8126
6358
  this._projectionMatrix,
8127
- this._fov * DEG2RAD,
6359
+ this._fov * shared.DEG2RAD,
8128
6360
  this._aspect,
8129
6361
  this._near,
8130
6362
  this._far
8131
6363
  );
8132
- const quakeToGl = import_gl_matrix.mat4.fromValues(
6364
+ const quakeToGl = glMatrix.mat4.fromValues(
8133
6365
  0,
8134
6366
  0,
8135
6367
  -1,
@@ -8154,21 +6386,21 @@ var Camera = class {
8154
6386
  const pitch = this._angles[0] + this._bobAngles[0] + this._kickAngles[0];
8155
6387
  const yaw = this._angles[1] + this._bobAngles[1] + this._kickAngles[1];
8156
6388
  const roll = this._angles[2] + this._bobAngles[2] + this._kickAngles[2] + this._rollAngle;
8157
- const pitchRad = pitch * DEG2RAD;
8158
- const yawRad = yaw * DEG2RAD;
8159
- const rollRad = roll * DEG2RAD;
8160
- const rotationQuake = import_gl_matrix.mat4.create();
8161
- import_gl_matrix.mat4.identity(rotationQuake);
8162
- import_gl_matrix.mat4.rotateZ(rotationQuake, rotationQuake, -yawRad);
8163
- import_gl_matrix.mat4.rotateY(rotationQuake, rotationQuake, -pitchRad);
8164
- import_gl_matrix.mat4.rotateX(rotationQuake, rotationQuake, -rollRad);
8165
- const rotationGl = import_gl_matrix.mat4.create();
8166
- import_gl_matrix.mat4.multiply(rotationGl, quakeToGl, rotationQuake);
8167
- const positionWithOffset = import_gl_matrix.vec3.add(import_gl_matrix.vec3.create(), this._position, this._bobOffset);
8168
- const negativePosition = import_gl_matrix.vec3.negate(import_gl_matrix.vec3.create(), positionWithOffset);
8169
- const rotatedPosQuake = import_gl_matrix.vec3.create();
8170
- import_gl_matrix.vec3.transformMat4(rotatedPosQuake, negativePosition, rotationQuake);
8171
- const translationGl = import_gl_matrix.vec3.fromValues(
6389
+ const pitchRad = pitch * shared.DEG2RAD;
6390
+ const yawRad = yaw * shared.DEG2RAD;
6391
+ const rollRad = roll * shared.DEG2RAD;
6392
+ const rotationQuake = glMatrix.mat4.create();
6393
+ glMatrix.mat4.identity(rotationQuake);
6394
+ glMatrix.mat4.rotateZ(rotationQuake, rotationQuake, -yawRad);
6395
+ glMatrix.mat4.rotateY(rotationQuake, rotationQuake, -pitchRad);
6396
+ glMatrix.mat4.rotateX(rotationQuake, rotationQuake, -rollRad);
6397
+ const rotationGl = glMatrix.mat4.create();
6398
+ glMatrix.mat4.multiply(rotationGl, quakeToGl, rotationQuake);
6399
+ const positionWithOffset = glMatrix.vec3.add(glMatrix.vec3.create(), this._position, this._bobOffset);
6400
+ const negativePosition = glMatrix.vec3.negate(glMatrix.vec3.create(), positionWithOffset);
6401
+ const rotatedPosQuake = glMatrix.vec3.create();
6402
+ glMatrix.vec3.transformMat4(rotatedPosQuake, negativePosition, rotationQuake);
6403
+ const translationGl = glMatrix.vec3.fromValues(
8172
6404
  rotatedPosQuake[1] ? -rotatedPosQuake[1] : 0,
8173
6405
  // Y in Quake -> -X in WebGL
8174
6406
  rotatedPosQuake[2] || 0,
@@ -8176,11 +6408,11 @@ var Camera = class {
8176
6408
  rotatedPosQuake[0] ? -rotatedPosQuake[0] : 0
8177
6409
  // X in Quake -> -Z in WebGL
8178
6410
  );
8179
- import_gl_matrix.mat4.copy(this._viewMatrix, rotationGl);
6411
+ glMatrix.mat4.copy(this._viewMatrix, rotationGl);
8180
6412
  this._viewMatrix[12] = translationGl[0];
8181
6413
  this._viewMatrix[13] = translationGl[1];
8182
6414
  this._viewMatrix[14] = translationGl[2];
8183
- import_gl_matrix.mat4.multiply(
6415
+ glMatrix.mat4.multiply(
8184
6416
  this._viewProjectionMatrix,
8185
6417
  this._projectionMatrix,
8186
6418
  this._viewMatrix
@@ -8188,8 +6420,6 @@ var Camera = class {
8188
6420
  this._dirty = false;
8189
6421
  }
8190
6422
  };
8191
-
8192
- // src/render/md3Pipeline.ts
8193
6423
  var DEFAULT_AMBIENT = [0.2, 0.2, 0.2];
8194
6424
  var DEFAULT_DIRECTION = { x: 0, y: 0, z: 1 };
8195
6425
  var DEFAULT_DIRECTION_COLOR = [0.8, 0.8, 0.8];
@@ -8228,14 +6458,14 @@ function buildMd3SurfaceGeometry(surface) {
8228
6458
  function evaluateLighting(normal, position, lighting) {
8229
6459
  const ambient = lighting?.ambient ?? DEFAULT_AMBIENT;
8230
6460
  const directional = lighting?.directional ?? { direction: DEFAULT_DIRECTION, color: DEFAULT_DIRECTION_COLOR };
8231
- const n = normalizeVec3(normal);
8232
- const l = normalizeVec3(directional.direction);
6461
+ const n = shared.normalizeVec3(normal);
6462
+ const l = shared.normalizeVec3(directional.direction);
8233
6463
  const ndotl = clamp012(n.x * l.x + n.y * l.y + n.z * l.z);
8234
6464
  let r = ambient[0] + directional.color[0] * ndotl;
8235
6465
  let g = ambient[1] + directional.color[1] * ndotl;
8236
6466
  let b = ambient[2] + directional.color[2] * ndotl;
8237
6467
  if (lighting?.dynamicLights) {
8238
- const worldPos = lighting.modelMatrix ? transformPointMat4(lighting.modelMatrix, position) : position;
6468
+ const worldPos = lighting.modelMatrix ? shared.transformPointMat4(lighting.modelMatrix, position) : position;
8239
6469
  for (const light of lighting.dynamicLights) {
8240
6470
  const dx = worldPos.x - light.origin.x;
8241
6471
  const dy = worldPos.y - light.origin.y;
@@ -8269,7 +6499,7 @@ function buildMd3VertexData(surface, geometry, blend, lighting) {
8269
6499
  throw new Error(`Vertex index ${vertex.vertexIndex} missing for frame`);
8270
6500
  }
8271
6501
  const position = lerpVec32(vA.position, vB.position, blend.lerp);
8272
- const normal = normalizeVec3(lerpVec32(vA.normal, vB.normal, blend.lerp));
6502
+ const normal = shared.normalizeVec3(lerpVec32(vA.normal, vB.normal, blend.lerp));
8273
6503
  const color = evaluateLighting(normal, position, lighting);
8274
6504
  const base = index * 12;
8275
6505
  data[base] = position.x;
@@ -8302,22 +6532,22 @@ function interpolateMd3Tag(model, blend, tagName) {
8302
6532
  throw new Error(`Tag ${tagName} is missing for one of the interpolated frames`);
8303
6533
  }
8304
6534
  const origin = lerpVec32(tagA.origin, tagB.origin, blend.lerp);
8305
- const axis0 = normalizeVec3(lerpVec32(tagA.axis[0], tagB.axis[0], blend.lerp));
8306
- const axis1 = normalizeVec3(lerpVec32(tagA.axis[1], tagB.axis[1], blend.lerp));
8307
- const axis2 = normalizeVec3(lerpVec32(tagA.axis[2], tagB.axis[2], blend.lerp));
6535
+ const axis0 = shared.normalizeVec3(lerpVec32(tagA.axis[0], tagB.axis[0], blend.lerp));
6536
+ const axis1 = shared.normalizeVec3(lerpVec32(tagA.axis[1], tagB.axis[1], blend.lerp));
6537
+ shared.normalizeVec3(lerpVec32(tagA.axis[2], tagB.axis[2], blend.lerp));
8308
6538
  const corrected0 = axis0;
8309
- const corrected1 = normalizeVec3({
6539
+ const corrected1 = shared.normalizeVec3({
8310
6540
  x: axis1.x - corrected0.x * (corrected0.x * axis1.x + corrected0.y * axis1.y + corrected0.z * axis1.z),
8311
6541
  y: axis1.y - corrected0.y * (corrected0.x * axis1.x + corrected0.y * axis1.y + corrected0.z * axis1.z),
8312
6542
  z: axis1.z - corrected0.z * (corrected0.x * axis1.x + corrected0.y * axis1.y + corrected0.z * axis1.z)
8313
6543
  });
8314
- const corrected2 = normalizeVec3({
6544
+ const corrected2 = shared.normalizeVec3({
8315
6545
  x: corrected0.y * corrected1.z - corrected0.z * corrected1.y,
8316
6546
  y: corrected0.z * corrected1.x - corrected0.x * corrected1.z,
8317
6547
  z: corrected0.x * corrected1.y - corrected0.y * corrected1.x
8318
6548
  });
8319
6549
  const axis = [corrected0, corrected1, corrected2];
8320
- return { origin, axis, matrix: mat4FromBasis(origin, axis) };
6550
+ return { origin, axis, matrix: shared.mat4FromBasis(origin, axis) };
8321
6551
  }
8322
6552
  var MD3_VERTEX_SHADER = `#version 300 es
8323
6553
  precision highp float;
@@ -9044,8 +7274,6 @@ function spawnRailTrail(context) {
9044
7274
  blendMode: "additive",
9045
7275
  fade: true
9046
7276
  });
9047
- const radius = 3;
9048
- const theta = d * 0.5;
9049
7277
  system.spawn({
9050
7278
  position: {
9051
7279
  x: x + (system.rng.frandom() - 0.5) * 6,
@@ -9244,8 +7472,6 @@ var SpriteRenderer = class {
9244
7472
  this.draw(x, y, width, height, 0, 0, 1, 1, color);
9245
7473
  }
9246
7474
  };
9247
-
9248
- // src/demo/demoReader.ts
9249
7475
  var DemoReader = class {
9250
7476
  constructor(buffer) {
9251
7477
  this.messageOffsets = [];
@@ -9305,7 +7531,7 @@ var DemoReader = class {
9305
7531
  this.offset += length;
9306
7532
  return {
9307
7533
  length,
9308
- data: new BinaryStream(blockData)
7534
+ data: new shared.BinaryStream(blockData)
9309
7535
  };
9310
7536
  }
9311
7537
  /**
@@ -9337,7 +7563,7 @@ var DemoReader = class {
9337
7563
  */
9338
7564
  readAllBlocksToBuffer() {
9339
7565
  let totalLength = 0;
9340
- const currentOffset = this.offset;
7566
+ this.offset;
9341
7567
  const blockInfos = [];
9342
7568
  let tempOffset = this.offset;
9343
7569
  while (tempOffset + 4 <= this.buffer.byteLength) {
@@ -11604,14 +9830,11 @@ var Deflate_1$1 = Deflate$1;
11604
9830
  var deflate_2 = deflate$1;
11605
9831
  var deflateRaw_1$1 = deflateRaw$1;
11606
9832
  var gzip_1$1 = gzip$1;
11607
- var constants$1 = constants$2;
11608
9833
  var deflate_1$1 = {
11609
9834
  Deflate: Deflate_1$1,
11610
9835
  deflate: deflate_2,
11611
9836
  deflateRaw: deflateRaw_1$1,
11612
- gzip: gzip_1$1,
11613
- constants: constants$1
11614
- };
9837
+ gzip: gzip_1$1};
11615
9838
  var BAD$1 = 16209;
11616
9839
  var TYPE$1 = 16191;
11617
9840
  var inffast = function inflate_fast(strm, start) {
@@ -13561,14 +11784,11 @@ var Inflate_1$1 = Inflate$1;
13561
11784
  var inflate_2 = inflate$1;
13562
11785
  var inflateRaw_1$1 = inflateRaw$1;
13563
11786
  var ungzip$1 = inflate$1;
13564
- var constants = constants$2;
13565
11787
  var inflate_1$1 = {
13566
11788
  Inflate: Inflate_1$1,
13567
11789
  inflate: inflate_2,
13568
11790
  inflateRaw: inflateRaw_1$1,
13569
- ungzip: ungzip$1,
13570
- constants
13571
- };
11791
+ ungzip: ungzip$1};
13572
11792
  var { Deflate, deflate, deflateRaw, gzip } = deflate_1$1;
13573
11793
  var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
13574
11794
  var Deflate_1 = Deflate;
@@ -13793,41 +12013,41 @@ var StreamingBuffer = _StreamingBuffer;
13793
12013
 
13794
12014
  // src/demo/parser.ts
13795
12015
  var PROTOCOL_VERSION_RERELEASE = 2023;
13796
- var U_ORIGIN12 = 1 << 0;
13797
- var U_ORIGIN22 = 1 << 1;
13798
- var U_ANGLE22 = 1 << 2;
13799
- var U_ANGLE32 = 1 << 3;
13800
- var U_FRAME82 = 1 << 4;
13801
- var U_EVENT2 = 1 << 5;
13802
- var U_REMOVE2 = 1 << 6;
13803
- var U_MOREBITS12 = 1 << 7;
13804
- var U_NUMBER162 = 1 << 8;
13805
- var U_ORIGIN32 = 1 << 9;
13806
- var U_ANGLE12 = 1 << 10;
13807
- var U_MODEL5 = 1 << 11;
13808
- var U_RENDERFX82 = 1 << 12;
13809
- var U_ALPHA2 = 1 << 13;
13810
- var U_EFFECTS82 = 1 << 14;
13811
- var U_MOREBITS22 = 1 << 15;
13812
- var U_SKIN82 = 1 << 16;
13813
- var U_FRAME162 = 1 << 17;
13814
- var U_RENDERFX162 = 1 << 18;
13815
- var U_EFFECTS162 = 1 << 19;
13816
- var U_MODEL22 = 1 << 20;
13817
- var U_MODEL32 = 1 << 21;
13818
- var U_MODEL42 = 1 << 22;
13819
- var U_MOREBITS32 = 1 << 23;
13820
- var U_OLDORIGIN2 = 1 << 24;
13821
- var U_SKIN162 = 1 << 25;
13822
- var U_SOUND2 = 1 << 26;
13823
- var U_SOLID2 = 1 << 27;
13824
- var U_SCALE2 = 1 << 28;
13825
- var U_INSTANCE_BITS2 = 1 << 29;
13826
- var U_LOOP_VOLUME2 = 1 << 30;
13827
- var U_MOREBITS42 = 2147483648 | 0;
13828
- var U_LOOP_ATTENUATION_HIGH2 = 1 << 0;
13829
- var U_OWNER_HIGH2 = 1 << 1;
13830
- var U_OLD_FRAME_HIGH2 = 1 << 2;
12016
+ var U_ORIGIN1 = 1 << 0;
12017
+ var U_ORIGIN2 = 1 << 1;
12018
+ var U_ANGLE2 = 1 << 2;
12019
+ var U_ANGLE3 = 1 << 3;
12020
+ var U_FRAME8 = 1 << 4;
12021
+ var U_EVENT = 1 << 5;
12022
+ var U_REMOVE = 1 << 6;
12023
+ var U_MOREBITS1 = 1 << 7;
12024
+ var U_NUMBER16 = 1 << 8;
12025
+ var U_ORIGIN3 = 1 << 9;
12026
+ var U_ANGLE1 = 1 << 10;
12027
+ var U_MODEL = 1 << 11;
12028
+ var U_RENDERFX8 = 1 << 12;
12029
+ var U_ALPHA = 1 << 13;
12030
+ var U_EFFECTS8 = 1 << 14;
12031
+ var U_MOREBITS2 = 1 << 15;
12032
+ var U_SKIN8 = 1 << 16;
12033
+ var U_FRAME16 = 1 << 17;
12034
+ var U_RENDERFX16 = 1 << 18;
12035
+ var U_EFFECTS16 = 1 << 19;
12036
+ var U_MODEL2 = 1 << 20;
12037
+ var U_MODEL3 = 1 << 21;
12038
+ var U_MODEL4 = 1 << 22;
12039
+ var U_MOREBITS3 = 1 << 23;
12040
+ var U_OLDORIGIN = 1 << 24;
12041
+ var U_SKIN16 = 1 << 25;
12042
+ var U_SOUND = 1 << 26;
12043
+ var U_SOLID = 1 << 27;
12044
+ var U_SCALE = 1 << 28;
12045
+ var U_INSTANCE_BITS = 1 << 29;
12046
+ var U_LOOP_VOLUME = 1 << 30;
12047
+ var U_MOREBITS4 = 2147483648 | 0;
12048
+ var U_LOOP_ATTENUATION_HIGH = 1 << 0;
12049
+ var U_OWNER_HIGH = 1 << 1;
12050
+ var U_OLD_FRAME_HIGH = 1 << 2;
13831
12051
  var RECORD_CLIENT = 1;
13832
12052
  var RECORD_SERVER = 2;
13833
12053
  var RECORD_RELAY = 128;
@@ -13920,29 +12140,29 @@ var BinaryStreamAdapter = class extends StreamingBuffer {
13920
12140
  }
13921
12141
  };
13922
12142
  var PROTO34_MAP = {
13923
- 0: ServerCommand.bad,
13924
- 1: ServerCommand.nop,
13925
- 2: ServerCommand.disconnect,
13926
- 3: ServerCommand.reconnect,
13927
- 4: ServerCommand.download,
13928
- 5: ServerCommand.frame,
13929
- 6: ServerCommand.inventory,
13930
- 7: ServerCommand.layout,
13931
- 8: ServerCommand.muzzleflash,
13932
- 9: ServerCommand.sound,
13933
- 10: ServerCommand.print,
13934
- 11: ServerCommand.stufftext,
13935
- 12: ServerCommand.serverdata,
13936
- 13: ServerCommand.configstring,
13937
- 14: ServerCommand.spawnbaseline,
13938
- 15: ServerCommand.centerprint,
13939
- 16: ServerCommand.download,
13940
- 17: ServerCommand.playerinfo,
13941
- 18: ServerCommand.packetentities,
13942
- 19: ServerCommand.deltapacketentities,
13943
- 23: ServerCommand.temp_entity,
12143
+ 0: shared.ServerCommand.bad,
12144
+ 1: shared.ServerCommand.nop,
12145
+ 2: shared.ServerCommand.disconnect,
12146
+ 3: shared.ServerCommand.reconnect,
12147
+ 4: shared.ServerCommand.download,
12148
+ 5: shared.ServerCommand.frame,
12149
+ 6: shared.ServerCommand.inventory,
12150
+ 7: shared.ServerCommand.layout,
12151
+ 8: shared.ServerCommand.muzzleflash,
12152
+ 9: shared.ServerCommand.sound,
12153
+ 10: shared.ServerCommand.print,
12154
+ 11: shared.ServerCommand.stufftext,
12155
+ 12: shared.ServerCommand.serverdata,
12156
+ 13: shared.ServerCommand.configstring,
12157
+ 14: shared.ServerCommand.spawnbaseline,
12158
+ 15: shared.ServerCommand.centerprint,
12159
+ 16: shared.ServerCommand.download,
12160
+ 17: shared.ServerCommand.playerinfo,
12161
+ 18: shared.ServerCommand.packetentities,
12162
+ 19: shared.ServerCommand.deltapacketentities,
12163
+ 23: shared.ServerCommand.temp_entity,
13944
12164
  // Wire 23 -> Enum 3 (TempEntity)
13945
- 22: ServerCommand.muzzleflash2
12165
+ 22: shared.ServerCommand.muzzleflash2
13946
12166
  // Wire 22 -> Enum 2 (MuzzleFlash2)
13947
12167
  };
13948
12168
  var NetworkMessageParser = class _NetworkMessageParser {
@@ -13951,7 +12171,7 @@ var NetworkMessageParser = class _NetworkMessageParser {
13951
12171
  this.isDemo = RECORD_CLIENT;
13952
12172
  this.strictMode = false;
13953
12173
  this.errorCount = 0;
13954
- if (stream instanceof BinaryStream) {
12174
+ if (stream instanceof shared.BinaryStream) {
13955
12175
  this.stream = new BinaryStreamAdapter(stream);
13956
12176
  } else {
13957
12177
  this.stream = stream;
@@ -13970,26 +12190,26 @@ var NetworkMessageParser = class _NetworkMessageParser {
13970
12190
  }
13971
12191
  translateCommand(cmd) {
13972
12192
  if (this.protocolVersion === 0) {
13973
- if (cmd === 7) return ServerCommand.serverdata;
13974
- if (cmd === 12) return ServerCommand.serverdata;
12193
+ if (cmd === 7) return shared.ServerCommand.serverdata;
12194
+ if (cmd === 12) return shared.ServerCommand.serverdata;
13975
12195
  return cmd;
13976
12196
  }
13977
12197
  if (this.protocolVersion === PROTOCOL_VERSION_RERELEASE) {
13978
12198
  return cmd;
13979
12199
  }
13980
12200
  if (this.protocolVersion === 25 || this.protocolVersion === 26) {
13981
- if (cmd === 0) return ServerCommand.bad;
12201
+ if (cmd === 0) return shared.ServerCommand.bad;
13982
12202
  const translated = cmd + 5;
13983
- if (translated >= ServerCommand.nop && translated <= ServerCommand.frame) {
12203
+ if (translated >= shared.ServerCommand.nop && translated <= shared.ServerCommand.frame) {
13984
12204
  return translated;
13985
12205
  }
13986
- return ServerCommand.bad;
12206
+ return shared.ServerCommand.bad;
13987
12207
  }
13988
12208
  if (this.protocolVersion === 34) {
13989
12209
  if (PROTO34_MAP[cmd] !== void 0) {
13990
12210
  return PROTO34_MAP[cmd];
13991
12211
  }
13992
- return ServerCommand.bad;
12212
+ return shared.ServerCommand.bad;
13993
12213
  }
13994
12214
  return cmd;
13995
12215
  }
@@ -14003,104 +12223,104 @@ var NetworkMessageParser = class _NetworkMessageParser {
14003
12223
  const originalCmd = cmd;
14004
12224
  cmd = this.translateCommand(cmd);
14005
12225
  switch (cmd) {
14006
- case ServerCommand.bad:
12226
+ case shared.ServerCommand.bad:
14007
12227
  return;
14008
- case ServerCommand.nop:
12228
+ case shared.ServerCommand.nop:
14009
12229
  break;
14010
- case ServerCommand.disconnect:
12230
+ case shared.ServerCommand.disconnect:
14011
12231
  if (this.handler?.onDisconnect) this.handler.onDisconnect();
14012
12232
  break;
14013
- case ServerCommand.reconnect:
12233
+ case shared.ServerCommand.reconnect:
14014
12234
  if (this.handler?.onReconnect) this.handler.onReconnect();
14015
12235
  break;
14016
- case ServerCommand.print:
12236
+ case shared.ServerCommand.print:
14017
12237
  this.parsePrint();
14018
12238
  break;
14019
- case ServerCommand.serverdata:
12239
+ case shared.ServerCommand.serverdata:
14020
12240
  this.parseServerData();
14021
12241
  break;
14022
- case ServerCommand.configstring:
12242
+ case shared.ServerCommand.configstring:
14023
12243
  this.parseConfigString();
14024
12244
  break;
14025
- case ServerCommand.spawnbaseline:
12245
+ case shared.ServerCommand.spawnbaseline:
14026
12246
  this.parseSpawnBaseline();
14027
12247
  break;
14028
- case ServerCommand.centerprint:
12248
+ case shared.ServerCommand.centerprint:
14029
12249
  this.parseCenterPrint();
14030
12250
  break;
14031
- case ServerCommand.download:
12251
+ case shared.ServerCommand.download:
14032
12252
  this.parseDownload();
14033
12253
  break;
14034
- case ServerCommand.frame:
12254
+ case shared.ServerCommand.frame:
14035
12255
  this.parseFrame();
14036
12256
  break;
14037
- case ServerCommand.packetentities:
12257
+ case shared.ServerCommand.packetentities:
14038
12258
  this.parsePacketEntities(false);
14039
12259
  break;
14040
- case ServerCommand.deltapacketentities:
12260
+ case shared.ServerCommand.deltapacketentities:
14041
12261
  this.parsePacketEntities(true);
14042
12262
  break;
14043
- case ServerCommand.playerinfo:
12263
+ case shared.ServerCommand.playerinfo:
14044
12264
  this.parsePlayerState();
14045
12265
  break;
14046
- case ServerCommand.stufftext:
12266
+ case shared.ServerCommand.stufftext:
14047
12267
  this.parseStuffText();
14048
12268
  break;
14049
- case ServerCommand.layout:
12269
+ case shared.ServerCommand.layout:
14050
12270
  this.parseLayout();
14051
12271
  break;
14052
- case ServerCommand.inventory:
12272
+ case shared.ServerCommand.inventory:
14053
12273
  this.parseInventory();
14054
12274
  break;
14055
- case ServerCommand.sound:
12275
+ case shared.ServerCommand.sound:
14056
12276
  this.parseSound();
14057
12277
  break;
14058
- case ServerCommand.muzzleflash:
12278
+ case shared.ServerCommand.muzzleflash:
14059
12279
  this.parseMuzzleFlash();
14060
12280
  break;
14061
- case ServerCommand.muzzleflash2:
12281
+ case shared.ServerCommand.muzzleflash2:
14062
12282
  this.parseMuzzleFlash2();
14063
12283
  break;
14064
- case ServerCommand.temp_entity:
12284
+ case shared.ServerCommand.temp_entity:
14065
12285
  this.parseTempEntity();
14066
12286
  break;
14067
- case ServerCommand.splitclient:
12287
+ case shared.ServerCommand.splitclient:
14068
12288
  this.parseSplitClient();
14069
12289
  break;
14070
- case ServerCommand.configblast:
12290
+ case shared.ServerCommand.configblast:
14071
12291
  this.parseConfigBlast();
14072
12292
  break;
14073
- case ServerCommand.spawnbaselineblast:
12293
+ case shared.ServerCommand.spawnbaselineblast:
14074
12294
  this.parseSpawnBaselineBlast();
14075
12295
  break;
14076
- case ServerCommand.level_restart:
12296
+ case shared.ServerCommand.level_restart:
14077
12297
  if (this.handler?.onLevelRestart) this.handler.onLevelRestart();
14078
12298
  break;
14079
- case ServerCommand.damage:
12299
+ case shared.ServerCommand.damage:
14080
12300
  this.parseDamage();
14081
12301
  break;
14082
- case ServerCommand.locprint:
12302
+ case shared.ServerCommand.locprint:
14083
12303
  this.parseLocPrint();
14084
12304
  break;
14085
- case ServerCommand.fog:
12305
+ case shared.ServerCommand.fog:
14086
12306
  this.parseFog();
14087
12307
  break;
14088
- case ServerCommand.waitingforplayers:
12308
+ case shared.ServerCommand.waitingforplayers:
14089
12309
  this.parseWaitingForPlayers();
14090
12310
  break;
14091
- case ServerCommand.bot_chat:
12311
+ case shared.ServerCommand.bot_chat:
14092
12312
  this.parseBotChat();
14093
12313
  break;
14094
- case ServerCommand.poi:
12314
+ case shared.ServerCommand.poi:
14095
12315
  this.parsePoi();
14096
12316
  break;
14097
- case ServerCommand.help_path:
12317
+ case shared.ServerCommand.help_path:
14098
12318
  this.parseHelpPath();
14099
12319
  break;
14100
- case ServerCommand.muzzleflash3:
12320
+ case shared.ServerCommand.muzzleflash3:
14101
12321
  this.parseMuzzleFlash3();
14102
12322
  break;
14103
- case ServerCommand.achievement:
12323
+ case shared.ServerCommand.achievement:
14104
12324
  this.parseAchievement();
14105
12325
  break;
14106
12326
  default:
@@ -14144,12 +12364,12 @@ var NetworkMessageParser = class _NetworkMessageParser {
14144
12364
  }
14145
12365
  readDir(out) {
14146
12366
  const b = this.stream.readByte();
14147
- if (b >= ANORMS.length) {
12367
+ if (b >= shared.ANORMS.length) {
14148
12368
  out.x = 0;
14149
12369
  out.y = 0;
14150
12370
  out.z = 0;
14151
12371
  } else {
14152
- const n = ANORMS[b];
12372
+ const n = shared.ANORMS[b];
14153
12373
  out.x = n[0];
14154
12374
  out.y = n[1];
14155
12375
  out.z = n[2];
@@ -14211,11 +12431,11 @@ var NetworkMessageParser = class _NetworkMessageParser {
14211
12431
  }
14212
12432
  parseConfigBlast() {
14213
12433
  const compressedSize = this.stream.readShort();
14214
- const uncompressedSize = this.stream.readShort();
12434
+ this.stream.readShort();
14215
12435
  const compressedData = this.stream.readData(compressedSize);
14216
12436
  try {
14217
12437
  const decompressed = pako.inflate(compressedData);
14218
- const blastStream = new BinaryStream(decompressed.buffer);
12438
+ const blastStream = new shared.BinaryStream(decompressed.buffer);
14219
12439
  while (blastStream.hasMore()) {
14220
12440
  const index = blastStream.readUShort();
14221
12441
  const str = blastStream.readString();
@@ -14227,11 +12447,11 @@ var NetworkMessageParser = class _NetworkMessageParser {
14227
12447
  }
14228
12448
  parseSpawnBaselineBlast() {
14229
12449
  const compressedSize = this.stream.readShort();
14230
- const uncompressedSize = this.stream.readShort();
12450
+ this.stream.readShort();
14231
12451
  const compressedData = this.stream.readData(compressedSize);
14232
12452
  try {
14233
12453
  const decompressed = pako.inflate(compressedData);
14234
- const blastStream = new BinaryStream(decompressed.buffer);
12454
+ const blastStream = new shared.BinaryStream(decompressed.buffer);
14235
12455
  const blastParser = new _NetworkMessageParser(blastStream, this.handler, this.strictMode);
14236
12456
  blastParser.setProtocolVersion(this.protocolVersion);
14237
12457
  while (blastStream.hasMore()) {
@@ -14254,23 +12474,23 @@ var NetworkMessageParser = class _NetworkMessageParser {
14254
12474
  if (this.handler?.onWaitingForPlayers) this.handler.onWaitingForPlayers(count);
14255
12475
  }
14256
12476
  parseBotChat() {
14257
- const botName = this.stream.readString();
14258
- const clientIndex = this.stream.readShort();
12477
+ this.stream.readString();
12478
+ this.stream.readShort();
14259
12479
  const locString = this.stream.readString();
14260
12480
  if (this.handler?.onBotChat) this.handler.onBotChat(locString);
14261
12481
  }
14262
12482
  parsePoi() {
14263
- const key = this.stream.readShort();
14264
- const time = this.stream.readShort();
12483
+ this.stream.readShort();
12484
+ this.stream.readShort();
14265
12485
  const pos = { x: 0, y: 0, z: 0 };
14266
12486
  this.readPos(pos);
14267
- const imageIndex = this.stream.readShort();
14268
- const paletteIndex = this.stream.readByte();
12487
+ this.stream.readShort();
12488
+ this.stream.readByte();
14269
12489
  const flags = this.stream.readByte();
14270
12490
  if (this.handler?.onPoi) this.handler.onPoi(flags, pos);
14271
12491
  }
14272
12492
  parseHelpPath() {
14273
- const start = this.stream.readByte();
12493
+ this.stream.readByte();
14274
12494
  const pos = { x: 0, y: 0, z: 0 };
14275
12495
  this.readPos(pos);
14276
12496
  const dir = { x: 0, y: 0, z: 0 };
@@ -14381,54 +12601,54 @@ var NetworkMessageParser = class _NetworkMessageParser {
14381
12601
  let srcEnt;
14382
12602
  let destEnt;
14383
12603
  switch (type) {
14384
- case TempEntity.EXPLOSION1:
14385
- case TempEntity.EXPLOSION2:
14386
- case TempEntity.ROCKET_EXPLOSION:
14387
- case TempEntity.GRENADE_EXPLOSION:
14388
- case TempEntity.ROCKET_EXPLOSION_WATER:
14389
- case TempEntity.GRENADE_EXPLOSION_WATER:
14390
- case TempEntity.BFG_EXPLOSION:
14391
- case TempEntity.BFG_BIGEXPLOSION:
14392
- case TempEntity.BOSSTPORT:
14393
- case TempEntity.PLASMA_EXPLOSION:
14394
- case TempEntity.PLAIN_EXPLOSION:
14395
- case TempEntity.CHAINFIST_SMOKE:
14396
- case TempEntity.TRACKER_EXPLOSION:
14397
- case TempEntity.TELEPORT_EFFECT:
14398
- case TempEntity.DBALL_GOAL:
14399
- case TempEntity.NUKEBLAST:
14400
- case TempEntity.WIDOWSPLASH:
14401
- case TempEntity.EXPLOSION1_BIG:
14402
- case TempEntity.EXPLOSION1_NP:
12604
+ case shared.TempEntity.EXPLOSION1:
12605
+ case shared.TempEntity.EXPLOSION2:
12606
+ case shared.TempEntity.ROCKET_EXPLOSION:
12607
+ case shared.TempEntity.GRENADE_EXPLOSION:
12608
+ case shared.TempEntity.ROCKET_EXPLOSION_WATER:
12609
+ case shared.TempEntity.GRENADE_EXPLOSION_WATER:
12610
+ case shared.TempEntity.BFG_EXPLOSION:
12611
+ case shared.TempEntity.BFG_BIGEXPLOSION:
12612
+ case shared.TempEntity.BOSSTPORT:
12613
+ case shared.TempEntity.PLASMA_EXPLOSION:
12614
+ case shared.TempEntity.PLAIN_EXPLOSION:
12615
+ case shared.TempEntity.CHAINFIST_SMOKE:
12616
+ case shared.TempEntity.TRACKER_EXPLOSION:
12617
+ case shared.TempEntity.TELEPORT_EFFECT:
12618
+ case shared.TempEntity.DBALL_GOAL:
12619
+ case shared.TempEntity.NUKEBLAST:
12620
+ case shared.TempEntity.WIDOWSPLASH:
12621
+ case shared.TempEntity.EXPLOSION1_BIG:
12622
+ case shared.TempEntity.EXPLOSION1_NP:
14403
12623
  this.readPos(pos);
14404
12624
  break;
14405
- case TempEntity.GUNSHOT:
14406
- case TempEntity.BLOOD:
14407
- case TempEntity.BLASTER:
14408
- case TempEntity.SHOTGUN:
14409
- case TempEntity.SPARKS:
14410
- case TempEntity.BULLET_SPARKS:
14411
- case TempEntity.SCREEN_SPARKS:
14412
- case TempEntity.SHIELD_SPARKS:
14413
- case TempEntity.BLASTER2:
14414
- case TempEntity.FLECHETTE:
14415
- case TempEntity.MOREBLOOD:
14416
- case TempEntity.ELECTRIC_SPARKS:
14417
- case TempEntity.HEATBEAM_SPARKS:
14418
- case TempEntity.HEATBEAM_STEAM:
12625
+ case shared.TempEntity.GUNSHOT:
12626
+ case shared.TempEntity.BLOOD:
12627
+ case shared.TempEntity.BLASTER:
12628
+ case shared.TempEntity.SHOTGUN:
12629
+ case shared.TempEntity.SPARKS:
12630
+ case shared.TempEntity.BULLET_SPARKS:
12631
+ case shared.TempEntity.SCREEN_SPARKS:
12632
+ case shared.TempEntity.SHIELD_SPARKS:
12633
+ case shared.TempEntity.BLASTER2:
12634
+ case shared.TempEntity.FLECHETTE:
12635
+ case shared.TempEntity.MOREBLOOD:
12636
+ case shared.TempEntity.ELECTRIC_SPARKS:
12637
+ case shared.TempEntity.HEATBEAM_SPARKS:
12638
+ case shared.TempEntity.HEATBEAM_STEAM:
14419
12639
  this.readPos(pos);
14420
12640
  this.readDir(dir);
14421
12641
  break;
14422
- case TempEntity.SPLASH:
14423
- case TempEntity.LASER_SPARKS:
14424
- case TempEntity.WELDING_SPARKS:
14425
- case TempEntity.TUNNEL_SPARKS:
12642
+ case shared.TempEntity.SPLASH:
12643
+ case shared.TempEntity.LASER_SPARKS:
12644
+ case shared.TempEntity.WELDING_SPARKS:
12645
+ case shared.TempEntity.TUNNEL_SPARKS:
14426
12646
  cnt = this.stream.readByte();
14427
12647
  this.readPos(pos);
14428
12648
  this.readDir(dir);
14429
12649
  color = this.stream.readByte();
14430
12650
  break;
14431
- case TempEntity.BLUEHYPERBLASTER:
12651
+ case shared.TempEntity.BLUEHYPERBLASTER:
14432
12652
  if (this.protocolVersion >= 32) {
14433
12653
  this.readPos(pos);
14434
12654
  this.readPos(pos2);
@@ -14437,7 +12657,7 @@ var NetworkMessageParser = class _NetworkMessageParser {
14437
12657
  this.readDir(dir);
14438
12658
  }
14439
12659
  break;
14440
- case TempEntity.GREENBLOOD:
12660
+ case shared.TempEntity.GREENBLOOD:
14441
12661
  if (this.protocolVersion >= 32) {
14442
12662
  this.readPos(pos);
14443
12663
  this.readDir(dir);
@@ -14446,42 +12666,42 @@ var NetworkMessageParser = class _NetworkMessageParser {
14446
12666
  this.readPos(pos2);
14447
12667
  }
14448
12668
  break;
14449
- case TempEntity.RAILTRAIL:
14450
- case TempEntity.BUBBLETRAIL:
14451
- case TempEntity.BFG_LASER:
14452
- case TempEntity.DEBUGTRAIL:
14453
- case TempEntity.BUBBLETRAIL2:
12669
+ case shared.TempEntity.RAILTRAIL:
12670
+ case shared.TempEntity.BUBBLETRAIL:
12671
+ case shared.TempEntity.BFG_LASER:
12672
+ case shared.TempEntity.DEBUGTRAIL:
12673
+ case shared.TempEntity.BUBBLETRAIL2:
14454
12674
  this.readPos(pos);
14455
12675
  this.readPos(pos2);
14456
12676
  break;
14457
- case TempEntity.PARASITE_ATTACK:
14458
- case TempEntity.MEDIC_CABLE_ATTACK:
12677
+ case shared.TempEntity.PARASITE_ATTACK:
12678
+ case shared.TempEntity.MEDIC_CABLE_ATTACK:
14459
12679
  this.stream.readShort();
14460
12680
  this.readPos(pos);
14461
12681
  this.readPos(pos2);
14462
12682
  break;
14463
- case TempEntity.GRAPPLE_CABLE:
12683
+ case shared.TempEntity.GRAPPLE_CABLE:
14464
12684
  ent = this.stream.readShort();
14465
12685
  this.readPos(pos);
14466
12686
  this.readPos(pos2);
14467
12687
  this.readPos(dir);
14468
12688
  break;
14469
- case TempEntity.LIGHTNING:
12689
+ case shared.TempEntity.LIGHTNING:
14470
12690
  srcEnt = this.stream.readShort();
14471
12691
  destEnt = this.stream.readShort();
14472
12692
  this.readPos(pos);
14473
12693
  this.readPos(pos2);
14474
12694
  break;
14475
- case TempEntity.FLASHLIGHT:
12695
+ case shared.TempEntity.FLASHLIGHT:
14476
12696
  this.readPos(pos);
14477
12697
  ent = this.stream.readShort();
14478
12698
  break;
14479
- case TempEntity.FORCEWALL:
12699
+ case shared.TempEntity.FORCEWALL:
14480
12700
  this.readPos(pos);
14481
12701
  this.readPos(pos2);
14482
12702
  color = this.stream.readByte();
14483
12703
  break;
14484
- case TempEntity.STEAM:
12704
+ case shared.TempEntity.STEAM:
14485
12705
  const nextId = this.stream.readShort();
14486
12706
  cnt = this.stream.readByte();
14487
12707
  this.readPos(pos);
@@ -14490,10 +12710,10 @@ var NetworkMessageParser = class _NetworkMessageParser {
14490
12710
  this.stream.readShort();
14491
12711
  if (nextId !== -1) this.stream.readLong();
14492
12712
  break;
14493
- case TempEntity.WIDOWBEAMOUT:
12713
+ case shared.TempEntity.WIDOWBEAMOUT:
14494
12714
  this.stream.readShort();
14495
- case TempEntity.HEATBEAM:
14496
- case TempEntity.MONSTER_HEATBEAM:
12715
+ case shared.TempEntity.HEATBEAM:
12716
+ case shared.TempEntity.MONSTER_HEATBEAM:
14497
12717
  ent = this.stream.readShort();
14498
12718
  this.readPos(pos);
14499
12719
  this.readPos(pos2);
@@ -14519,14 +12739,14 @@ var NetworkMessageParser = class _NetworkMessageParser {
14519
12739
  const areaBits = this.stream.readData(areaBytes);
14520
12740
  let piCmd = this.stream.readByte();
14521
12741
  piCmd = this.translateCommand(piCmd);
14522
- if (piCmd !== ServerCommand.playerinfo) {
12742
+ if (piCmd !== shared.ServerCommand.playerinfo) {
14523
12743
  if (this.strictMode) throw new Error(`Expected svc_playerinfo after svc_frame, got ${piCmd}`);
14524
12744
  return;
14525
12745
  }
14526
12746
  const playerState = this.parsePlayerState();
14527
12747
  let peCmd = this.stream.readByte();
14528
12748
  peCmd = this.translateCommand(peCmd);
14529
- if (peCmd !== ServerCommand.packetentities && peCmd !== ServerCommand.deltapacketentities) {
12749
+ if (peCmd !== shared.ServerCommand.packetentities && peCmd !== shared.ServerCommand.deltapacketentities) {
14530
12750
  if (this.strictMode) throw new Error(`Expected svc_packetentities after svc_playerinfo, got ${peCmd}`);
14531
12751
  return;
14532
12752
  }
@@ -14622,12 +12842,12 @@ var NetworkMessageParser = class _NetworkMessageParser {
14622
12842
  const entities = [];
14623
12843
  while (true) {
14624
12844
  const bits = this.parseEntityBits();
14625
- if (bits.bits & U_REMOVE2) {
12845
+ if (bits.bits & U_REMOVE) {
14626
12846
  if (bits.number === 0) break;
14627
12847
  continue;
14628
12848
  }
14629
12849
  const entity = createEmptyEntityState();
14630
- const forceParse = bits.number === 0 && !(bits.bits & U_MOREBITS12);
12850
+ const forceParse = bits.number === 0 && !(bits.bits & U_MOREBITS1);
14631
12851
  if (bits.number !== 0 || forceParse) {
14632
12852
  this.parseDelta(createEmptyEntityState(), entity, bits.number, bits.bits, bits.bitsHigh);
14633
12853
  }
@@ -14638,15 +12858,15 @@ var NetworkMessageParser = class _NetworkMessageParser {
14638
12858
  }
14639
12859
  parseEntityBits() {
14640
12860
  let total = this.stream.readByte();
14641
- if (total & U_MOREBITS12) total |= this.stream.readByte() << 8;
14642
- if (total & U_MOREBITS22) total |= this.stream.readByte() << 16;
14643
- if (total & U_MOREBITS32) total |= this.stream.readByte() << 24;
12861
+ if (total & U_MOREBITS1) total |= this.stream.readByte() << 8;
12862
+ if (total & U_MOREBITS2) total |= this.stream.readByte() << 16;
12863
+ if (total & U_MOREBITS3) total |= this.stream.readByte() << 24;
14644
12864
  let bitsHigh = 0;
14645
12865
  if (this.protocolVersion === PROTOCOL_VERSION_RERELEASE) {
14646
- if (total & U_MOREBITS42) bitsHigh = this.stream.readByte();
12866
+ if (total & U_MOREBITS4) bitsHigh = this.stream.readByte();
14647
12867
  }
14648
12868
  let number;
14649
- if (total & U_NUMBER162) number = this.stream.readShort();
12869
+ if (total & U_NUMBER16) number = this.stream.readShort();
14650
12870
  else number = this.stream.readByte();
14651
12871
  return { number, bits: total, bitsHigh };
14652
12872
  }
@@ -14682,40 +12902,40 @@ var NetworkMessageParser = class _NetworkMessageParser {
14682
12902
  to.number = number;
14683
12903
  to.bits = bits;
14684
12904
  to.bitsHigh = bitsHigh;
14685
- if (bits & U_MODEL5) to.modelindex = this.stream.readByte();
14686
- if (bits & U_MODEL22) to.modelindex2 = this.stream.readByte();
14687
- if (bits & U_MODEL32) to.modelindex3 = this.stream.readByte();
14688
- if (bits & U_MODEL42) to.modelindex4 = this.stream.readByte();
14689
- if (bits & U_FRAME82) to.frame = this.stream.readByte();
14690
- if (bits & U_FRAME162) to.frame = this.stream.readShort();
14691
- if (bits & U_SKIN82 && bits & U_SKIN162) to.skinnum = this.stream.readLong();
14692
- else if (bits & U_SKIN82) to.skinnum = this.stream.readByte();
14693
- else if (bits & U_SKIN162) to.skinnum = this.stream.readShort();
14694
- if (bits & U_EFFECTS82 && bits & U_EFFECTS162) to.effects = this.stream.readLong();
14695
- else if (bits & U_EFFECTS82) to.effects = this.stream.readByte();
14696
- else if (bits & U_EFFECTS162) to.effects = this.stream.readShort();
14697
- if (bits & U_RENDERFX82 && bits & U_RENDERFX162) to.renderfx = this.stream.readLong();
14698
- else if (bits & U_RENDERFX82) to.renderfx = this.stream.readByte();
14699
- else if (bits & U_RENDERFX162) to.renderfx = this.stream.readShort();
14700
- if (bits & U_ORIGIN12) to.origin.x = this.readCoord();
14701
- if (bits & U_ORIGIN22) to.origin.y = this.readCoord();
14702
- if (bits & U_ORIGIN32) to.origin.z = this.readCoord();
14703
- if (bits & U_ANGLE12) to.angles.x = this.readAngle();
14704
- if (bits & U_ANGLE22) to.angles.y = this.readAngle();
14705
- if (bits & U_ANGLE32) to.angles.z = this.readAngle();
14706
- if (bits & U_OLDORIGIN2) this.readPos(to.old_origin);
14707
- if (bits & U_SOUND2) to.sound = this.stream.readByte();
14708
- if (bits & U_EVENT2) to.event = this.stream.readByte();
12905
+ if (bits & U_MODEL) to.modelindex = this.stream.readByte();
12906
+ if (bits & U_MODEL2) to.modelindex2 = this.stream.readByte();
12907
+ if (bits & U_MODEL3) to.modelindex3 = this.stream.readByte();
12908
+ if (bits & U_MODEL4) to.modelindex4 = this.stream.readByte();
12909
+ if (bits & U_FRAME8) to.frame = this.stream.readByte();
12910
+ if (bits & U_FRAME16) to.frame = this.stream.readShort();
12911
+ if (bits & U_SKIN8 && bits & U_SKIN16) to.skinnum = this.stream.readLong();
12912
+ else if (bits & U_SKIN8) to.skinnum = this.stream.readByte();
12913
+ else if (bits & U_SKIN16) to.skinnum = this.stream.readShort();
12914
+ if (bits & U_EFFECTS8 && bits & U_EFFECTS16) to.effects = this.stream.readLong();
12915
+ else if (bits & U_EFFECTS8) to.effects = this.stream.readByte();
12916
+ else if (bits & U_EFFECTS16) to.effects = this.stream.readShort();
12917
+ if (bits & U_RENDERFX8 && bits & U_RENDERFX16) to.renderfx = this.stream.readLong();
12918
+ else if (bits & U_RENDERFX8) to.renderfx = this.stream.readByte();
12919
+ else if (bits & U_RENDERFX16) to.renderfx = this.stream.readShort();
12920
+ if (bits & U_ORIGIN1) to.origin.x = this.readCoord();
12921
+ if (bits & U_ORIGIN2) to.origin.y = this.readCoord();
12922
+ if (bits & U_ORIGIN3) to.origin.z = this.readCoord();
12923
+ if (bits & U_ANGLE1) to.angles.x = this.readAngle();
12924
+ if (bits & U_ANGLE2) to.angles.y = this.readAngle();
12925
+ if (bits & U_ANGLE3) to.angles.z = this.readAngle();
12926
+ if (bits & U_OLDORIGIN) this.readPos(to.old_origin);
12927
+ if (bits & U_SOUND) to.sound = this.stream.readByte();
12928
+ if (bits & U_EVENT) to.event = this.stream.readByte();
14709
12929
  else to.event = 0;
14710
- if (bits & U_SOLID2) to.solid = this.stream.readShort();
12930
+ if (bits & U_SOLID) to.solid = this.stream.readShort();
14711
12931
  if (this.protocolVersion === PROTOCOL_VERSION_RERELEASE) {
14712
- if (bits & U_ALPHA2) to.alpha = this.stream.readByte() / 255;
14713
- if (bits & U_SCALE2) to.scale = this.stream.readFloat();
14714
- if (bits & U_INSTANCE_BITS2) to.instanceBits = this.stream.readLong();
14715
- if (bits & U_LOOP_VOLUME2) to.loopVolume = this.stream.readByte() / 255;
14716
- if (bitsHigh & U_LOOP_ATTENUATION_HIGH2) to.loopAttenuation = this.stream.readByte() / 255;
14717
- if (bitsHigh & U_OWNER_HIGH2) to.owner = this.stream.readShort();
14718
- if (bitsHigh & U_OLD_FRAME_HIGH2) to.oldFrame = this.stream.readShort();
12932
+ if (bits & U_ALPHA) to.alpha = this.stream.readByte() / 255;
12933
+ if (bits & U_SCALE) to.scale = this.stream.readFloat();
12934
+ if (bits & U_INSTANCE_BITS) to.instanceBits = this.stream.readLong();
12935
+ if (bits & U_LOOP_VOLUME) to.loopVolume = this.stream.readByte() / 255;
12936
+ if (bitsHigh & U_LOOP_ATTENUATION_HIGH) to.loopAttenuation = this.stream.readByte() / 255;
12937
+ if (bitsHigh & U_OWNER_HIGH) to.owner = this.stream.readShort();
12938
+ if (bitsHigh & U_OLD_FRAME_HIGH) to.oldFrame = this.stream.readShort();
14719
12939
  }
14720
12940
  }
14721
12941
  };
@@ -14807,8 +13027,7 @@ var DemoAnalyzer = class {
14807
13027
  }
14808
13028
  }
14809
13029
  this.activeEntities = currentFrameEntities;
14810
- if (frame.playerState && this.header) {
14811
- }
13030
+ if (frame.playerState && this.header) ;
14812
13031
  },
14813
13032
  onPrint: (level, msg) => {
14814
13033
  const text = msg.replace(/\n/g, " ").trim();
@@ -15188,8 +13407,7 @@ var DemoPlaybackController = class {
15188
13407
  playRange(start, end) {
15189
13408
  const startFrame = start.type === "frame" ? start.frame : this.timeToFrame(start.seconds);
15190
13409
  const endFrame = end.type === "frame" ? end.frame : this.timeToFrame(end.seconds);
15191
- const totalFrames = this.getTotalFrames();
15192
- const maxFrame = Math.max(0, totalFrames - 1);
13410
+ this.getTotalFrames();
15193
13411
  if (startFrame < 0) {
15194
13412
  throw new Error(`Invalid start offset: ${startFrame}`);
15195
13413
  }
@@ -15265,8 +13483,7 @@ var DemoPlaybackController = class {
15265
13483
  }
15266
13484
  }
15267
13485
  while (this.currentFrameIndex < frameNumber) {
15268
- if (this.callbacks?.onCaptureSnapshot && (this.currentFrameIndex + 1) % this.snapshotInterval === 0) {
15269
- }
13486
+ if (this.callbacks?.onCaptureSnapshot && (this.currentFrameIndex + 1) % this.snapshotInterval === 0) ;
15270
13487
  if (!this.processNextFrame()) {
15271
13488
  break;
15272
13489
  }
@@ -15495,8 +13712,7 @@ var DemoPlaybackController = class {
15495
13712
  if (!header) return null;
15496
13713
  const serverInfo = this.getDemoServerInfo();
15497
13714
  let playerName = "Unknown";
15498
- if (this.cachedConfigStrings) {
15499
- }
13715
+ if (this.cachedConfigStrings) ;
15500
13716
  return {
15501
13717
  mapName: header.levelName,
15502
13718
  playerName,
@@ -15617,7 +13833,7 @@ var DemoPlaybackController = class {
15617
13833
  async playRangeWithTracking(start, end, tracker, options = {}) {
15618
13834
  this.tracker = tracker;
15619
13835
  tracker.startTracking();
15620
- const startFrame = start.type === "frame" ? start.frame : this.timeToFrame(start.seconds);
13836
+ start.type === "frame" ? start.frame : this.timeToFrame(start.seconds);
15621
13837
  const endFrame = end.type === "frame" ? end.frame : this.timeToFrame(end.seconds);
15622
13838
  if (options.fastForward) {
15623
13839
  try {
@@ -15675,8 +13891,6 @@ var DemoPlaybackController = class {
15675
13891
  }
15676
13892
  }
15677
13893
  };
15678
-
15679
- // src/demo/recorder.ts
15680
13894
  var DemoRecorder = class {
15681
13895
  // -1 means start of demo
15682
13896
  constructor() {
@@ -15685,7 +13899,7 @@ var DemoRecorder = class {
15685
13899
  this.frameCount = 0;
15686
13900
  this.filename = null;
15687
13901
  this.lastMessageSize = -1;
15688
- this.messageBuffer = new BinaryWriter(1024 * 1024);
13902
+ this.messageBuffer = new shared.BinaryWriter(1024 * 1024);
15689
13903
  }
15690
13904
  startRecording(filename, startTime = 0) {
15691
13905
  if (this.isRecording) return;
@@ -15715,31 +13929,29 @@ var DemoRecorder = class {
15715
13929
  return this.isRecording;
15716
13930
  }
15717
13931
  };
15718
-
15719
- // src/demo/writer.ts
15720
13932
  var PROTO34_REVERSE_MAP = {
15721
- [ServerCommand.bad]: 0,
15722
- [ServerCommand.nop]: 1,
15723
- [ServerCommand.disconnect]: 2,
15724
- [ServerCommand.reconnect]: 3,
13933
+ [shared.ServerCommand.bad]: 0,
13934
+ [shared.ServerCommand.nop]: 1,
13935
+ [shared.ServerCommand.disconnect]: 2,
13936
+ [shared.ServerCommand.reconnect]: 3,
15725
13937
  // 4 is download? standard Q2 uses 4 for download sometimes, but let's stick to parser map (download=16).
15726
13938
  // Let's map download to 16.
15727
- [ServerCommand.download]: 16,
15728
- [ServerCommand.frame]: 5,
15729
- [ServerCommand.inventory]: 6,
15730
- [ServerCommand.layout]: 7,
15731
- [ServerCommand.muzzleflash]: 8,
15732
- [ServerCommand.sound]: 9,
15733
- [ServerCommand.print]: 10,
15734
- [ServerCommand.stufftext]: 11,
15735
- [ServerCommand.serverdata]: 12,
15736
- [ServerCommand.configstring]: 13,
15737
- [ServerCommand.spawnbaseline]: 14,
15738
- [ServerCommand.centerprint]: 15,
13939
+ [shared.ServerCommand.download]: 16,
13940
+ [shared.ServerCommand.frame]: 5,
13941
+ [shared.ServerCommand.inventory]: 6,
13942
+ [shared.ServerCommand.layout]: 7,
13943
+ [shared.ServerCommand.muzzleflash]: 8,
13944
+ [shared.ServerCommand.sound]: 9,
13945
+ [shared.ServerCommand.print]: 10,
13946
+ [shared.ServerCommand.stufftext]: 11,
13947
+ [shared.ServerCommand.serverdata]: 12,
13948
+ [shared.ServerCommand.configstring]: 13,
13949
+ [shared.ServerCommand.spawnbaseline]: 14,
13950
+ [shared.ServerCommand.centerprint]: 15,
15739
13951
  // 16 is download
15740
- [ServerCommand.playerinfo]: 17,
15741
- [ServerCommand.packetentities]: 18,
15742
- [ServerCommand.deltapacketentities]: 19,
13952
+ [shared.ServerCommand.playerinfo]: 17,
13953
+ [shared.ServerCommand.packetentities]: 18,
13954
+ [shared.ServerCommand.deltapacketentities]: 19,
15743
13955
  // Temp entity? Standard Q2 uses 9 for temp_entity?
15744
13956
  // But we mapped 9 to sound.
15745
13957
  // If we map temp_entity to 23 (arbitrary safe slot for internal tests) or assume standard Q2 layout:
@@ -15753,14 +13965,14 @@ var PROTO34_REVERSE_MAP = {
15753
13965
  // Parser does NOT map any wire code to TempEntity in my recent edit (I commented out 23).
15754
13966
  // So TempEntity is currently broken for Protocol 34 unless I map it.
15755
13967
  // I will map TempEntity to 23 in both.
15756
- [ServerCommand.temp_entity]: 23,
13968
+ [shared.ServerCommand.temp_entity]: 23,
15757
13969
  // MuzzleFlash2?
15758
13970
  // I'll map it to 22 (arbitrary) just to have a value, or skip if unused.
15759
- [ServerCommand.muzzleflash2]: 22
13971
+ [shared.ServerCommand.muzzleflash2]: 22
15760
13972
  };
15761
13973
  var MessageWriter = class {
15762
13974
  constructor() {
15763
- this.writer = new BinaryWriter();
13975
+ this.writer = new shared.BinaryWriter();
15764
13976
  }
15765
13977
  getData() {
15766
13978
  return this.writer.getData();
@@ -15776,7 +13988,7 @@ var MessageWriter = class {
15776
13988
  this.writer.writeByte(cmd);
15777
13989
  }
15778
13990
  writeServerData(protocol, serverCount, attractLoop, gameDir, playerNum, levelName) {
15779
- this.writeCommand(ServerCommand.serverdata, protocol);
13991
+ this.writeCommand(shared.ServerCommand.serverdata, protocol);
15780
13992
  this.writer.writeLong(protocol);
15781
13993
  this.writer.writeLong(serverCount);
15782
13994
  this.writer.writeByte(attractLoop);
@@ -15785,7 +13997,7 @@ var MessageWriter = class {
15785
13997
  this.writer.writeString(levelName);
15786
13998
  }
15787
13999
  writeServerDataRerelease(protocol, spawnCount, demoType, tickRate, gameDir, playerNum, levelName) {
15788
- this.writeCommand(ServerCommand.serverdata, protocol);
14000
+ this.writeCommand(shared.ServerCommand.serverdata, protocol);
15789
14001
  this.writer.writeLong(protocol);
15790
14002
  this.writer.writeLong(spawnCount);
15791
14003
  this.writer.writeByte(demoType);
@@ -15795,99 +14007,99 @@ var MessageWriter = class {
15795
14007
  this.writer.writeString(levelName);
15796
14008
  }
15797
14009
  writeConfigString(index, str, protocolVersion = 0) {
15798
- this.writeCommand(ServerCommand.configstring, protocolVersion);
14010
+ this.writeCommand(shared.ServerCommand.configstring, protocolVersion);
15799
14011
  this.writer.writeShort(index);
15800
14012
  this.writer.writeString(str);
15801
14013
  }
15802
14014
  writeSpawnBaseline(entity, protocolVersion) {
15803
- this.writeCommand(ServerCommand.spawnbaseline, protocolVersion);
14015
+ this.writeCommand(shared.ServerCommand.spawnbaseline, protocolVersion);
15804
14016
  this.writeEntityState(entity, null, true, protocolVersion);
15805
14017
  }
15806
14018
  writeStuffText(text, protocolVersion = 0) {
15807
- this.writeCommand(ServerCommand.stufftext, protocolVersion);
14019
+ this.writeCommand(shared.ServerCommand.stufftext, protocolVersion);
15808
14020
  this.writer.writeString(text);
15809
14021
  }
15810
14022
  writeCenterPrint(text, protocolVersion = 0) {
15811
- this.writeCommand(ServerCommand.centerprint, protocolVersion);
14023
+ this.writeCommand(shared.ServerCommand.centerprint, protocolVersion);
15812
14024
  this.writer.writeString(text);
15813
14025
  }
15814
14026
  writePrint(level, text, protocolVersion = 0) {
15815
- this.writeCommand(ServerCommand.print, protocolVersion);
14027
+ this.writeCommand(shared.ServerCommand.print, protocolVersion);
15816
14028
  this.writer.writeByte(level);
15817
14029
  this.writer.writeString(text);
15818
14030
  }
15819
14031
  writeLayout(layout, protocolVersion = 0) {
15820
- this.writeCommand(ServerCommand.layout, protocolVersion);
14032
+ this.writeCommand(shared.ServerCommand.layout, protocolVersion);
15821
14033
  this.writer.writeString(layout);
15822
14034
  }
15823
14035
  writeInventory(inventory, protocolVersion = 0) {
15824
- this.writeCommand(ServerCommand.inventory, protocolVersion);
14036
+ this.writeCommand(shared.ServerCommand.inventory, protocolVersion);
15825
14037
  for (let i = 0; i < 256; i++) {
15826
14038
  this.writer.writeShort(inventory[i] || 0);
15827
14039
  }
15828
14040
  }
15829
14041
  writeMuzzleFlash(ent, weapon, protocolVersion = 0) {
15830
- this.writeCommand(ServerCommand.muzzleflash, protocolVersion);
14042
+ this.writeCommand(shared.ServerCommand.muzzleflash, protocolVersion);
15831
14043
  this.writer.writeShort(ent);
15832
14044
  this.writer.writeByte(weapon);
15833
14045
  }
15834
14046
  writeMuzzleFlash2(ent, weapon, protocolVersion = 0) {
15835
- this.writeCommand(ServerCommand.muzzleflash2, protocolVersion);
14047
+ this.writeCommand(shared.ServerCommand.muzzleflash2, protocolVersion);
15836
14048
  this.writer.writeShort(ent);
15837
14049
  this.writer.writeByte(weapon);
15838
14050
  }
15839
14051
  writeTempEntity(type, pos, pos2, dir, cnt, color, ent, srcEnt, destEnt, protocolVersion = 0) {
15840
- this.writeCommand(ServerCommand.temp_entity, protocolVersion);
14052
+ this.writeCommand(shared.ServerCommand.temp_entity, protocolVersion);
15841
14053
  this.writer.writeByte(type);
15842
14054
  switch (type) {
15843
- case TempEntity.EXPLOSION1:
15844
- case TempEntity.EXPLOSION2:
15845
- case TempEntity.ROCKET_EXPLOSION:
15846
- case TempEntity.GRENADE_EXPLOSION:
15847
- case TempEntity.ROCKET_EXPLOSION_WATER:
15848
- case TempEntity.GRENADE_EXPLOSION_WATER:
15849
- case TempEntity.BFG_EXPLOSION:
15850
- case TempEntity.BFG_BIGEXPLOSION:
15851
- case TempEntity.BOSSTPORT:
15852
- case TempEntity.PLASMA_EXPLOSION:
15853
- case TempEntity.PLAIN_EXPLOSION:
15854
- case TempEntity.CHAINFIST_SMOKE:
15855
- case TempEntity.TRACKER_EXPLOSION:
15856
- case TempEntity.TELEPORT_EFFECT:
15857
- case TempEntity.DBALL_GOAL:
15858
- case TempEntity.NUKEBLAST:
15859
- case TempEntity.WIDOWSPLASH:
15860
- case TempEntity.EXPLOSION1_BIG:
15861
- case TempEntity.EXPLOSION1_NP:
14055
+ case shared.TempEntity.EXPLOSION1:
14056
+ case shared.TempEntity.EXPLOSION2:
14057
+ case shared.TempEntity.ROCKET_EXPLOSION:
14058
+ case shared.TempEntity.GRENADE_EXPLOSION:
14059
+ case shared.TempEntity.ROCKET_EXPLOSION_WATER:
14060
+ case shared.TempEntity.GRENADE_EXPLOSION_WATER:
14061
+ case shared.TempEntity.BFG_EXPLOSION:
14062
+ case shared.TempEntity.BFG_BIGEXPLOSION:
14063
+ case shared.TempEntity.BOSSTPORT:
14064
+ case shared.TempEntity.PLASMA_EXPLOSION:
14065
+ case shared.TempEntity.PLAIN_EXPLOSION:
14066
+ case shared.TempEntity.CHAINFIST_SMOKE:
14067
+ case shared.TempEntity.TRACKER_EXPLOSION:
14068
+ case shared.TempEntity.TELEPORT_EFFECT:
14069
+ case shared.TempEntity.DBALL_GOAL:
14070
+ case shared.TempEntity.NUKEBLAST:
14071
+ case shared.TempEntity.WIDOWSPLASH:
14072
+ case shared.TempEntity.EXPLOSION1_BIG:
14073
+ case shared.TempEntity.EXPLOSION1_NP:
15862
14074
  this.writer.writePos(pos);
15863
14075
  break;
15864
- case TempEntity.GUNSHOT:
15865
- case TempEntity.BLOOD:
15866
- case TempEntity.BLASTER:
15867
- case TempEntity.SHOTGUN:
15868
- case TempEntity.SPARKS:
15869
- case TempEntity.BULLET_SPARKS:
15870
- case TempEntity.SCREEN_SPARKS:
15871
- case TempEntity.SHIELD_SPARKS:
15872
- case TempEntity.BLASTER2:
15873
- case TempEntity.FLECHETTE:
15874
- case TempEntity.MOREBLOOD:
15875
- case TempEntity.ELECTRIC_SPARKS:
15876
- case TempEntity.HEATBEAM_SPARKS:
15877
- case TempEntity.HEATBEAM_STEAM:
14076
+ case shared.TempEntity.GUNSHOT:
14077
+ case shared.TempEntity.BLOOD:
14078
+ case shared.TempEntity.BLASTER:
14079
+ case shared.TempEntity.SHOTGUN:
14080
+ case shared.TempEntity.SPARKS:
14081
+ case shared.TempEntity.BULLET_SPARKS:
14082
+ case shared.TempEntity.SCREEN_SPARKS:
14083
+ case shared.TempEntity.SHIELD_SPARKS:
14084
+ case shared.TempEntity.BLASTER2:
14085
+ case shared.TempEntity.FLECHETTE:
14086
+ case shared.TempEntity.MOREBLOOD:
14087
+ case shared.TempEntity.ELECTRIC_SPARKS:
14088
+ case shared.TempEntity.HEATBEAM_SPARKS:
14089
+ case shared.TempEntity.HEATBEAM_STEAM:
15878
14090
  this.writer.writePos(pos);
15879
14091
  this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
15880
14092
  break;
15881
- case TempEntity.SPLASH:
15882
- case TempEntity.LASER_SPARKS:
15883
- case TempEntity.WELDING_SPARKS:
15884
- case TempEntity.TUNNEL_SPARKS:
14093
+ case shared.TempEntity.SPLASH:
14094
+ case shared.TempEntity.LASER_SPARKS:
14095
+ case shared.TempEntity.WELDING_SPARKS:
14096
+ case shared.TempEntity.TUNNEL_SPARKS:
15885
14097
  this.writer.writeByte(cnt || 0);
15886
14098
  this.writer.writePos(pos);
15887
14099
  this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
15888
14100
  this.writer.writeByte(color || 0);
15889
14101
  break;
15890
- case TempEntity.BLUEHYPERBLASTER:
14102
+ case shared.TempEntity.BLUEHYPERBLASTER:
15891
14103
  if (protocolVersion >= 32) {
15892
14104
  this.writer.writePos(pos);
15893
14105
  this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
@@ -15896,7 +14108,7 @@ var MessageWriter = class {
15896
14108
  this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
15897
14109
  }
15898
14110
  break;
15899
- case TempEntity.GREENBLOOD:
14111
+ case shared.TempEntity.GREENBLOOD:
15900
14112
  if (protocolVersion >= 32) {
15901
14113
  this.writer.writePos(pos);
15902
14114
  this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
@@ -15905,42 +14117,42 @@ var MessageWriter = class {
15905
14117
  this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15906
14118
  }
15907
14119
  break;
15908
- case TempEntity.RAILTRAIL:
15909
- case TempEntity.BUBBLETRAIL:
15910
- case TempEntity.BFG_LASER:
15911
- case TempEntity.DEBUGTRAIL:
15912
- case TempEntity.BUBBLETRAIL2:
14120
+ case shared.TempEntity.RAILTRAIL:
14121
+ case shared.TempEntity.BUBBLETRAIL:
14122
+ case shared.TempEntity.BFG_LASER:
14123
+ case shared.TempEntity.DEBUGTRAIL:
14124
+ case shared.TempEntity.BUBBLETRAIL2:
15913
14125
  this.writer.writePos(pos);
15914
14126
  this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15915
14127
  break;
15916
- case TempEntity.PARASITE_ATTACK:
15917
- case TempEntity.MEDIC_CABLE_ATTACK:
14128
+ case shared.TempEntity.PARASITE_ATTACK:
14129
+ case shared.TempEntity.MEDIC_CABLE_ATTACK:
15918
14130
  this.writer.writeShort(ent || 0);
15919
14131
  this.writer.writePos(pos);
15920
14132
  this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15921
14133
  break;
15922
- case TempEntity.GRAPPLE_CABLE:
14134
+ case shared.TempEntity.GRAPPLE_CABLE:
15923
14135
  this.writer.writeShort(ent || 0);
15924
14136
  this.writer.writePos(pos);
15925
14137
  this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15926
14138
  this.writer.writePos(dir || { x: 0, y: 0, z: 0 });
15927
14139
  break;
15928
- case TempEntity.LIGHTNING:
14140
+ case shared.TempEntity.LIGHTNING:
15929
14141
  this.writer.writeShort(srcEnt || 0);
15930
14142
  this.writer.writeShort(destEnt || 0);
15931
14143
  this.writer.writePos(pos);
15932
14144
  this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15933
14145
  break;
15934
- case TempEntity.FLASHLIGHT:
14146
+ case shared.TempEntity.FLASHLIGHT:
15935
14147
  this.writer.writePos(pos);
15936
14148
  this.writer.writeShort(ent || 0);
15937
14149
  break;
15938
- case TempEntity.FORCEWALL:
14150
+ case shared.TempEntity.FORCEWALL:
15939
14151
  this.writer.writePos(pos);
15940
14152
  this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15941
14153
  this.writer.writeByte(color || 0);
15942
14154
  break;
15943
- case TempEntity.STEAM:
14155
+ case shared.TempEntity.STEAM:
15944
14156
  this.writer.writeShort(-1);
15945
14157
  this.writer.writeByte(cnt || 0);
15946
14158
  this.writer.writePos(pos);
@@ -15948,12 +14160,12 @@ var MessageWriter = class {
15948
14160
  this.writer.writeByte(color || 0);
15949
14161
  this.writer.writeShort(0);
15950
14162
  break;
15951
- case TempEntity.WIDOWBEAMOUT:
14163
+ case shared.TempEntity.WIDOWBEAMOUT:
15952
14164
  this.writer.writeShort(0);
15953
14165
  // ent
15954
14166
  // Fallthrough
15955
- case TempEntity.HEATBEAM:
15956
- case TempEntity.MONSTER_HEATBEAM:
14167
+ case shared.TempEntity.HEATBEAM:
14168
+ case shared.TempEntity.MONSTER_HEATBEAM:
15957
14169
  this.writer.writeShort(ent || 0);
15958
14170
  this.writer.writePos(pos);
15959
14171
  this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
@@ -15965,7 +14177,7 @@ var MessageWriter = class {
15965
14177
  }
15966
14178
  }
15967
14179
  writeSound(mask, soundNum, volume, attenuation, offset, ent, pos, protocolVersion = 0) {
15968
- this.writeCommand(ServerCommand.sound, protocolVersion);
14180
+ this.writeCommand(shared.ServerCommand.sound, protocolVersion);
15969
14181
  this.writer.writeByte(mask);
15970
14182
  this.writer.writeByte(soundNum);
15971
14183
  if (mask & 1) this.writer.writeByte(volume || 0);
@@ -15979,13 +14191,13 @@ var MessageWriter = class {
15979
14191
  }
15980
14192
  }
15981
14193
  writeDisconnect(protocolVersion = 0) {
15982
- this.writeCommand(ServerCommand.disconnect, protocolVersion);
14194
+ this.writeCommand(shared.ServerCommand.disconnect, protocolVersion);
15983
14195
  }
15984
14196
  writeReconnect(protocolVersion = 0) {
15985
- this.writeCommand(ServerCommand.reconnect, protocolVersion);
14197
+ this.writeCommand(shared.ServerCommand.reconnect, protocolVersion);
15986
14198
  }
15987
14199
  writeFrame(frame, protocolVersion) {
15988
- this.writeCommand(ServerCommand.frame, protocolVersion);
14200
+ this.writeCommand(shared.ServerCommand.frame, protocolVersion);
15989
14201
  this.writer.writeLong(frame.serverFrame);
15990
14202
  this.writer.writeLong(frame.deltaFrame);
15991
14203
  if (protocolVersion !== 25 && protocolVersion !== 26) {
@@ -15995,7 +14207,7 @@ var MessageWriter = class {
15995
14207
  if (frame.areaBytes > 0) {
15996
14208
  this.writer.writeBytes(frame.areaBits);
15997
14209
  }
15998
- this.writeCommand(ServerCommand.playerinfo, protocolVersion);
14210
+ this.writeCommand(shared.ServerCommand.playerinfo, protocolVersion);
15999
14211
  this.writePlayerState(frame.playerState);
16000
14212
  this.writePacketEntities(frame.packetEntities.entities, frame.packetEntities.delta, protocolVersion);
16001
14213
  }
@@ -16079,7 +14291,7 @@ var MessageWriter = class {
16079
14291
  }
16080
14292
  }
16081
14293
  writePacketEntities(entities, delta, protocolVersion) {
16082
- this.writeCommand(delta ? ServerCommand.deltapacketentities : ServerCommand.packetentities, protocolVersion);
14294
+ this.writeCommand(delta ? shared.ServerCommand.deltapacketentities : shared.ServerCommand.packetentities, protocolVersion);
16083
14295
  for (const ent of entities) {
16084
14296
  const force = !delta;
16085
14297
  this.writeEntityState(ent, null, force, protocolVersion);
@@ -16093,102 +14305,100 @@ var MessageWriter = class {
16093
14305
  bits = to.bits;
16094
14306
  bitsHigh = to.bitsHigh;
16095
14307
  } else {
16096
- if (to.modelindex !== 0) bits |= U_MODEL5;
16097
- if (to.modelindex2 !== 0) bits |= U_MODEL22;
16098
- if (to.modelindex3 !== 0) bits |= U_MODEL32;
16099
- if (to.modelindex4 !== 0) bits |= U_MODEL42;
14308
+ if (to.modelindex !== 0) bits |= U_MODEL;
14309
+ if (to.modelindex2 !== 0) bits |= U_MODEL2;
14310
+ if (to.modelindex3 !== 0) bits |= U_MODEL3;
14311
+ if (to.modelindex4 !== 0) bits |= U_MODEL4;
16100
14312
  if (to.frame !== 0) {
16101
- if (to.frame >= 256) bits |= U_FRAME162;
16102
- else bits |= U_FRAME82;
14313
+ if (to.frame >= 256) bits |= U_FRAME16;
14314
+ else bits |= U_FRAME8;
16103
14315
  }
16104
14316
  if (to.skinnum !== 0) {
16105
- if (to.skinnum >= 256) bits |= U_SKIN162;
16106
- else bits |= U_SKIN82;
14317
+ if (to.skinnum >= 256) bits |= U_SKIN16;
14318
+ else bits |= U_SKIN8;
16107
14319
  }
16108
14320
  if (to.effects !== 0) {
16109
- if (to.effects >= 256) bits |= U_EFFECTS162;
16110
- else bits |= U_EFFECTS82;
14321
+ if (to.effects >= 256) bits |= U_EFFECTS16;
14322
+ else bits |= U_EFFECTS8;
16111
14323
  }
16112
14324
  if (to.renderfx !== 0) {
16113
- if (to.renderfx >= 256) bits |= U_RENDERFX162;
16114
- else bits |= U_RENDERFX82;
16115
- }
16116
- if (to.origin.x !== 0) bits |= U_ORIGIN12;
16117
- if (to.origin.y !== 0) bits |= U_ORIGIN22;
16118
- if (to.origin.z !== 0) bits |= U_ORIGIN32;
16119
- if (to.angles.x !== 0) bits |= U_ANGLE12;
16120
- if (to.angles.y !== 0) bits |= U_ANGLE22;
16121
- if (to.angles.z !== 0) bits |= U_ANGLE32;
16122
- if (to.old_origin.x !== 0 || to.old_origin.y !== 0 || to.old_origin.z !== 0) bits |= U_OLDORIGIN2;
16123
- if (to.sound !== 0) bits |= U_SOUND2;
16124
- if (to.event !== 0) bits |= U_EVENT2;
16125
- if (to.solid !== 0) bits |= U_SOLID2;
14325
+ if (to.renderfx >= 256) bits |= U_RENDERFX16;
14326
+ else bits |= U_RENDERFX8;
14327
+ }
14328
+ if (to.origin.x !== 0) bits |= U_ORIGIN1;
14329
+ if (to.origin.y !== 0) bits |= U_ORIGIN2;
14330
+ if (to.origin.z !== 0) bits |= U_ORIGIN3;
14331
+ if (to.angles.x !== 0) bits |= U_ANGLE1;
14332
+ if (to.angles.y !== 0) bits |= U_ANGLE2;
14333
+ if (to.angles.z !== 0) bits |= U_ANGLE3;
14334
+ if (to.old_origin.x !== 0 || to.old_origin.y !== 0 || to.old_origin.z !== 0) bits |= U_OLDORIGIN;
14335
+ if (to.sound !== 0) bits |= U_SOUND;
14336
+ if (to.event !== 0) bits |= U_EVENT;
14337
+ if (to.solid !== 0) bits |= U_SOLID;
16126
14338
  if (protocolVersion >= 2023) {
16127
- if (to.alpha !== 0) bits |= U_ALPHA2;
16128
- if (to.scale !== 0) bits |= U_SCALE2;
16129
- if (to.instanceBits !== 0) bits |= U_INSTANCE_BITS2;
16130
- if (to.loopVolume !== 0) bits |= U_LOOP_VOLUME2;
16131
- if (to.loopAttenuation !== 0) bitsHigh |= U_LOOP_ATTENUATION_HIGH2;
16132
- if (to.owner !== 0) bitsHigh |= U_OWNER_HIGH2;
16133
- if (to.oldFrame !== 0) bitsHigh |= U_OLD_FRAME_HIGH2;
16134
- }
16135
- if (to.number >= 256) bits |= U_NUMBER162;
16136
- }
16137
- if (bitsHigh !== 0) bits |= U_MOREBITS42;
16138
- if ((bits & 4278190080) !== 0) bits |= U_MOREBITS32;
16139
- if ((bits & 16711680) !== 0) bits |= U_MOREBITS22;
16140
- if ((bits & 65280) !== 0) bits |= U_MOREBITS12;
14339
+ if (to.alpha !== 0) bits |= U_ALPHA;
14340
+ if (to.scale !== 0) bits |= U_SCALE;
14341
+ if (to.instanceBits !== 0) bits |= U_INSTANCE_BITS;
14342
+ if (to.loopVolume !== 0) bits |= U_LOOP_VOLUME;
14343
+ if (to.loopAttenuation !== 0) bitsHigh |= U_LOOP_ATTENUATION_HIGH;
14344
+ if (to.owner !== 0) bitsHigh |= U_OWNER_HIGH;
14345
+ if (to.oldFrame !== 0) bitsHigh |= U_OLD_FRAME_HIGH;
14346
+ }
14347
+ if (to.number >= 256) bits |= U_NUMBER16;
14348
+ }
14349
+ if (bitsHigh !== 0) bits |= U_MOREBITS4;
14350
+ if ((bits & 4278190080) !== 0) bits |= U_MOREBITS3;
14351
+ if ((bits & 16711680) !== 0) bits |= U_MOREBITS2;
14352
+ if ((bits & 65280) !== 0) bits |= U_MOREBITS1;
16141
14353
  this.writer.writeByte(bits & 255);
16142
- if (bits & U_MOREBITS12) this.writer.writeByte(bits >> 8 & 255);
16143
- if (bits & U_MOREBITS22) this.writer.writeByte(bits >> 16 & 255);
16144
- if (bits & U_MOREBITS32) this.writer.writeByte(bits >> 24 & 255);
16145
- if (protocolVersion >= 2023 && bits & U_MOREBITS42) {
14354
+ if (bits & U_MOREBITS1) this.writer.writeByte(bits >> 8 & 255);
14355
+ if (bits & U_MOREBITS2) this.writer.writeByte(bits >> 16 & 255);
14356
+ if (bits & U_MOREBITS3) this.writer.writeByte(bits >> 24 & 255);
14357
+ if (protocolVersion >= 2023 && bits & U_MOREBITS4) {
16146
14358
  this.writer.writeByte(bitsHigh & 255);
16147
14359
  }
16148
- if (bits & U_NUMBER162) this.writer.writeShort(to.number);
14360
+ if (bits & U_NUMBER16) this.writer.writeShort(to.number);
16149
14361
  else this.writer.writeByte(to.number);
16150
- if (bits & U_MODEL5) this.writer.writeByte(to.modelindex);
16151
- if (bits & U_MODEL22) this.writer.writeByte(to.modelindex2);
16152
- if (bits & U_MODEL32) this.writer.writeByte(to.modelindex3);
16153
- if (bits & U_MODEL42) this.writer.writeByte(to.modelindex4);
16154
- if (bits & U_FRAME82) this.writer.writeByte(to.frame);
16155
- if (bits & U_FRAME162) this.writer.writeShort(to.frame);
16156
- if (bits & U_SKIN82 && bits & U_SKIN162) this.writer.writeLong(to.skinnum);
16157
- else if (bits & U_SKIN82) this.writer.writeByte(to.skinnum);
16158
- else if (bits & U_SKIN162) this.writer.writeShort(to.skinnum);
16159
- if (bits & U_EFFECTS82 && bits & U_EFFECTS162) this.writer.writeLong(to.effects);
16160
- else if (bits & U_EFFECTS82) this.writer.writeByte(to.effects);
16161
- else if (bits & U_EFFECTS162) this.writer.writeShort(to.effects);
16162
- if (bits & U_RENDERFX82 && bits & U_RENDERFX162) this.writer.writeLong(to.renderfx);
16163
- else if (bits & U_RENDERFX82) this.writer.writeByte(to.renderfx);
16164
- else if (bits & U_RENDERFX162) this.writer.writeShort(to.renderfx);
16165
- if (bits & U_ORIGIN12) this.writer.writeCoord(to.origin.x);
16166
- if (bits & U_ORIGIN22) this.writer.writeCoord(to.origin.y);
16167
- if (bits & U_ORIGIN32) this.writer.writeCoord(to.origin.z);
16168
- if (bits & U_ANGLE12) this.writer.writeAngle(to.angles.x);
16169
- if (bits & U_ANGLE22) this.writer.writeAngle(to.angles.y);
16170
- if (bits & U_ANGLE32) this.writer.writeAngle(to.angles.z);
16171
- if (bits & U_OLDORIGIN2) {
14362
+ if (bits & U_MODEL) this.writer.writeByte(to.modelindex);
14363
+ if (bits & U_MODEL2) this.writer.writeByte(to.modelindex2);
14364
+ if (bits & U_MODEL3) this.writer.writeByte(to.modelindex3);
14365
+ if (bits & U_MODEL4) this.writer.writeByte(to.modelindex4);
14366
+ if (bits & U_FRAME8) this.writer.writeByte(to.frame);
14367
+ if (bits & U_FRAME16) this.writer.writeShort(to.frame);
14368
+ if (bits & U_SKIN8 && bits & U_SKIN16) this.writer.writeLong(to.skinnum);
14369
+ else if (bits & U_SKIN8) this.writer.writeByte(to.skinnum);
14370
+ else if (bits & U_SKIN16) this.writer.writeShort(to.skinnum);
14371
+ if (bits & U_EFFECTS8 && bits & U_EFFECTS16) this.writer.writeLong(to.effects);
14372
+ else if (bits & U_EFFECTS8) this.writer.writeByte(to.effects);
14373
+ else if (bits & U_EFFECTS16) this.writer.writeShort(to.effects);
14374
+ if (bits & U_RENDERFX8 && bits & U_RENDERFX16) this.writer.writeLong(to.renderfx);
14375
+ else if (bits & U_RENDERFX8) this.writer.writeByte(to.renderfx);
14376
+ else if (bits & U_RENDERFX16) this.writer.writeShort(to.renderfx);
14377
+ if (bits & U_ORIGIN1) this.writer.writeCoord(to.origin.x);
14378
+ if (bits & U_ORIGIN2) this.writer.writeCoord(to.origin.y);
14379
+ if (bits & U_ORIGIN3) this.writer.writeCoord(to.origin.z);
14380
+ if (bits & U_ANGLE1) this.writer.writeAngle(to.angles.x);
14381
+ if (bits & U_ANGLE2) this.writer.writeAngle(to.angles.y);
14382
+ if (bits & U_ANGLE3) this.writer.writeAngle(to.angles.z);
14383
+ if (bits & U_OLDORIGIN) {
16172
14384
  this.writer.writeCoord(to.old_origin.x);
16173
14385
  this.writer.writeCoord(to.old_origin.y);
16174
14386
  this.writer.writeCoord(to.old_origin.z);
16175
14387
  }
16176
- if (bits & U_SOUND2) this.writer.writeByte(to.sound);
16177
- if (bits & U_EVENT2) this.writer.writeByte(to.event);
16178
- if (bits & U_SOLID2) this.writer.writeShort(to.solid);
14388
+ if (bits & U_SOUND) this.writer.writeByte(to.sound);
14389
+ if (bits & U_EVENT) this.writer.writeByte(to.event);
14390
+ if (bits & U_SOLID) this.writer.writeShort(to.solid);
16179
14391
  if (protocolVersion >= 2023) {
16180
- if (bits & U_ALPHA2) this.writer.writeByte(Math.round(to.alpha * 255));
16181
- if (bits & U_SCALE2) this.writer.writeFloat(to.scale);
16182
- if (bits & U_INSTANCE_BITS2) this.writer.writeLong(to.instanceBits);
16183
- if (bits & U_LOOP_VOLUME2) this.writer.writeByte(Math.round(to.loopVolume * 255));
16184
- if (bitsHigh & U_LOOP_ATTENUATION_HIGH2) this.writer.writeByte(Math.round(to.loopAttenuation * 255));
16185
- if (bitsHigh & U_OWNER_HIGH2) this.writer.writeShort(to.owner);
16186
- if (bitsHigh & U_OLD_FRAME_HIGH2) this.writer.writeShort(to.oldFrame);
14392
+ if (bits & U_ALPHA) this.writer.writeByte(Math.round(to.alpha * 255));
14393
+ if (bits & U_SCALE) this.writer.writeFloat(to.scale);
14394
+ if (bits & U_INSTANCE_BITS) this.writer.writeLong(to.instanceBits);
14395
+ if (bits & U_LOOP_VOLUME) this.writer.writeByte(Math.round(to.loopVolume * 255));
14396
+ if (bitsHigh & U_LOOP_ATTENUATION_HIGH) this.writer.writeByte(Math.round(to.loopAttenuation * 255));
14397
+ if (bitsHigh & U_OWNER_HIGH) this.writer.writeShort(to.owner);
14398
+ if (bitsHigh & U_OLD_FRAME_HIGH) this.writer.writeShort(to.oldFrame);
16187
14399
  }
16188
14400
  }
16189
14401
  };
16190
-
16191
- // src/demo/validator.ts
16192
14402
  var DemoValidator = class {
16193
14403
  /**
16194
14404
  * Validates a Quake 2 demo file buffer.
@@ -16207,10 +14417,10 @@ var DemoValidator = class {
16207
14417
  return { valid: false, error: `Invalid first block length: ${length}` };
16208
14418
  }
16209
14419
  const firstCmd = view.getUint8(4);
16210
- if (firstCmd !== ServerCommand.serverdata) {
14420
+ if (firstCmd !== shared.ServerCommand.serverdata) {
16211
14421
  return {
16212
14422
  valid: false,
16213
- error: `First command is not svc_serverdata (expected ${ServerCommand.serverdata}, got ${firstCmd})`
14423
+ error: `First command is not svc_serverdata (expected ${shared.ServerCommand.serverdata}, got ${firstCmd})`
16214
14424
  };
16215
14425
  }
16216
14426
  let version = -1;
@@ -16220,11 +14430,9 @@ var DemoValidator = class {
16220
14430
  return { valid: true, version };
16221
14431
  }
16222
14432
  };
16223
-
16224
- // src/demo/demoWriter.ts
16225
14433
  var DemoWriter = class {
16226
14434
  constructor() {
16227
- this.writer = new BinaryWriter();
14435
+ this.writer = new shared.BinaryWriter();
16228
14436
  }
16229
14437
  writeBlock(data) {
16230
14438
  this.writer.writeLong(data.byteLength);
@@ -16243,36 +14451,36 @@ function applyEntityDelta(to, from) {
16243
14451
  const bits = from.bits;
16244
14452
  const bitsHigh = from.bitsHigh;
16245
14453
  to.number = from.number;
16246
- if (bits & U_MODEL5) to.modelindex = from.modelindex;
16247
- if (bits & U_MODEL22) to.modelindex2 = from.modelindex2;
16248
- if (bits & U_MODEL32) to.modelindex3 = from.modelindex3;
16249
- if (bits & U_MODEL42) to.modelindex4 = from.modelindex4;
16250
- if (bits & U_FRAME82) to.frame = from.frame;
16251
- if (bits & U_FRAME162) to.frame = from.frame;
16252
- if (bits & U_SKIN82 || bits & U_SKIN162) to.skinnum = from.skinnum;
16253
- if (bits & U_EFFECTS82 || bits & U_EFFECTS162) to.effects = from.effects;
16254
- if (bits & U_RENDERFX82 || bits & U_RENDERFX162) to.renderfx = from.renderfx;
16255
- if (bits & U_ORIGIN12) to.origin.x = from.origin.x;
16256
- if (bits & U_ORIGIN22) to.origin.y = from.origin.y;
16257
- if (bits & U_ORIGIN32) to.origin.z = from.origin.z;
16258
- if (bits & U_ANGLE12) to.angles.x = from.angles.x;
16259
- if (bits & U_ANGLE22) to.angles.y = from.angles.y;
16260
- if (bits & U_ANGLE32) to.angles.z = from.angles.z;
16261
- if (bits & U_OLDORIGIN2) {
14454
+ if (bits & U_MODEL) to.modelindex = from.modelindex;
14455
+ if (bits & U_MODEL2) to.modelindex2 = from.modelindex2;
14456
+ if (bits & U_MODEL3) to.modelindex3 = from.modelindex3;
14457
+ if (bits & U_MODEL4) to.modelindex4 = from.modelindex4;
14458
+ if (bits & U_FRAME8) to.frame = from.frame;
14459
+ if (bits & U_FRAME16) to.frame = from.frame;
14460
+ if (bits & U_SKIN8 || bits & U_SKIN16) to.skinnum = from.skinnum;
14461
+ if (bits & U_EFFECTS8 || bits & U_EFFECTS16) to.effects = from.effects;
14462
+ if (bits & U_RENDERFX8 || bits & U_RENDERFX16) to.renderfx = from.renderfx;
14463
+ if (bits & U_ORIGIN1) to.origin.x = from.origin.x;
14464
+ if (bits & U_ORIGIN2) to.origin.y = from.origin.y;
14465
+ if (bits & U_ORIGIN3) to.origin.z = from.origin.z;
14466
+ if (bits & U_ANGLE1) to.angles.x = from.angles.x;
14467
+ if (bits & U_ANGLE2) to.angles.y = from.angles.y;
14468
+ if (bits & U_ANGLE3) to.angles.z = from.angles.z;
14469
+ if (bits & U_OLDORIGIN) {
16262
14470
  to.old_origin.x = from.old_origin.x;
16263
14471
  to.old_origin.y = from.old_origin.y;
16264
14472
  to.old_origin.z = from.old_origin.z;
16265
14473
  }
16266
- if (bits & U_SOUND2) to.sound = from.sound;
16267
- if (bits & U_EVENT2) to.event = from.event;
16268
- if (bits & U_SOLID2) to.solid = from.solid;
16269
- if (bits & U_ALPHA2) to.alpha = from.alpha;
16270
- if (bits & U_SCALE2) to.scale = from.scale;
16271
- if (bits & U_INSTANCE_BITS2) to.instanceBits = from.instanceBits;
16272
- if (bits & U_LOOP_VOLUME2) to.loopVolume = from.loopVolume;
16273
- if (bitsHigh & U_LOOP_ATTENUATION_HIGH2) to.loopAttenuation = from.loopAttenuation;
16274
- if (bitsHigh & U_OWNER_HIGH2) to.owner = from.owner;
16275
- if (bitsHigh & U_OLD_FRAME_HIGH2) to.oldFrame = from.oldFrame;
14474
+ if (bits & U_SOUND) to.sound = from.sound;
14475
+ if (bits & U_EVENT) to.event = from.event;
14476
+ if (bits & U_SOLID) to.solid = from.solid;
14477
+ if (bits & U_ALPHA) to.alpha = from.alpha;
14478
+ if (bits & U_SCALE) to.scale = from.scale;
14479
+ if (bits & U_INSTANCE_BITS) to.instanceBits = from.instanceBits;
14480
+ if (bits & U_LOOP_VOLUME) to.loopVolume = from.loopVolume;
14481
+ if (bitsHigh & U_LOOP_ATTENUATION_HIGH) to.loopAttenuation = from.loopAttenuation;
14482
+ if (bitsHigh & U_OWNER_HIGH) to.owner = from.owner;
14483
+ if (bitsHigh & U_OLD_FRAME_HIGH) to.oldFrame = from.oldFrame;
16276
14484
  }
16277
14485
 
16278
14486
  // src/demo/clipper.ts
@@ -16349,7 +14557,7 @@ var DemoClipper = class {
16349
14557
  }
16350
14558
  }
16351
14559
  for (const deltaEnt of frame.packetEntities.entities) {
16352
- if (deltaEnt.bits & U_REMOVE2) {
14560
+ if (deltaEnt.bits & U_REMOVE) {
16353
14561
  newEntities.delete(deltaEnt.number);
16354
14562
  continue;
16355
14563
  }
@@ -16652,7 +14860,6 @@ function projectPoint(v, width, height, center, scale) {
16652
14860
  const z1 = v.z - center.z;
16653
14861
  const cosX = 0.866;
16654
14862
  const sinX = 0.5;
16655
- const y2 = y1 * cosX - z1 * sinX;
16656
14863
  const z2 = y1 * sinX + z1 * cosX;
16657
14864
  const screenX = width / 2 + x1 * scale;
16658
14865
  const screenY = height / 2 - z2 * scale;
@@ -16862,8 +15069,7 @@ function parseEntLump(text) {
16862
15069
  cursor++;
16863
15070
  const start = cursor;
16864
15071
  while (cursor < length && text[cursor] !== '"') {
16865
- if (text[cursor] === "\n") {
16866
- }
15072
+ if (text[cursor] === "\n") ;
16867
15073
  cursor++;
16868
15074
  }
16869
15075
  const token = text.substring(start, cursor);
@@ -16988,7 +15194,7 @@ async function createWebGPUContext(canvas, options) {
16988
15194
  };
16989
15195
  const device = await adapter.requestDevice(deviceDescriptor);
16990
15196
  let context;
16991
- let format = "bgra8unorm";
15197
+ let format = "rgba8unorm";
16992
15198
  let isHeadless = true;
16993
15199
  let width = 0;
16994
15200
  let height = 0;
@@ -17104,8 +15310,6 @@ async function captureRenderTarget(device, texture) {
17104
15310
  outputBuffer.unmap();
17105
15311
  return result;
17106
15312
  }
17107
-
17108
- // src/network/clientConnection.ts
17109
15313
  var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
17110
15314
  ConnectionState2[ConnectionState2["Disconnected"] = 0] = "Disconnected";
17111
15315
  ConnectionState2[ConnectionState2["Connecting"] = 1] = "Connecting";
@@ -17135,7 +15339,7 @@ var ClientConnection = class {
17135
15339
  this.currentPacketCRC = 0;
17136
15340
  this.commandHistory = [];
17137
15341
  this.options = options;
17138
- this.netchan = options.netchan ?? new NetChan();
15342
+ this.netchan = options.netchan ?? new shared.NetChan();
17139
15343
  }
17140
15344
  on(event, callback) {
17141
15345
  if (!this.listeners[event]) {
@@ -17204,8 +15408,8 @@ var ClientConnection = class {
17204
15408
  if (!processedData || processedData.byteLength === 0) {
17205
15409
  return;
17206
15410
  }
17207
- this.currentPacketCRC = crc8(processedData);
17208
- const stream = new BinaryStream(processedData.buffer);
15411
+ this.currentPacketCRC = shared.crc8(processedData);
15412
+ const stream = new shared.BinaryStream(processedData.buffer);
17209
15413
  this.parser = new NetworkMessageParser(stream, this);
17210
15414
  if (this.serverProtocol) {
17211
15415
  this.parser.setProtocolVersion(this.serverProtocol);
@@ -17222,15 +15426,15 @@ var ClientConnection = class {
17222
15426
  serverFrame: cmd.serverFrame ?? this.latestServerFrame
17223
15427
  };
17224
15428
  this.commandHistory.push(commandWithFrame);
17225
- if (this.commandHistory.length > CMD_BACKUP) {
15429
+ if (this.commandHistory.length > shared.CMD_BACKUP) {
17226
15430
  this.commandHistory.shift();
17227
15431
  }
17228
- const writer = new BinaryWriter();
17229
- writer.writeByte(ClientCommand.move);
15432
+ const writer = new shared.BinaryWriter();
15433
+ writer.writeByte(shared.ClientCommand.move);
17230
15434
  const checksum = this.frameCRCs.get(this.latestServerFrame) || 0;
17231
15435
  writer.writeByte(checksum);
17232
15436
  writer.writeLong(this.latestServerFrame);
17233
- writeUserCommand(writer, commandWithFrame);
15437
+ shared.writeUserCommand(writer, commandWithFrame);
17234
15438
  this.transmit(writer.getData());
17235
15439
  }
17236
15440
  transmit(data) {
@@ -17238,27 +15442,27 @@ var ClientConnection = class {
17238
15442
  this.emit("send", packet);
17239
15443
  }
17240
15444
  sendChallenge() {
17241
- const builder = new NetworkMessageBuilder();
17242
- builder.writeByte(ClientCommand.stringcmd);
15445
+ const builder = new shared.NetworkMessageBuilder();
15446
+ builder.writeByte(shared.ClientCommand.stringcmd);
17243
15447
  builder.writeString("getchallenge");
17244
15448
  this.transmit(builder.getData());
17245
15449
  }
17246
15450
  sendConnect(challenge) {
17247
- const builder = new NetworkMessageBuilder();
17248
- builder.writeByte(ClientCommand.stringcmd);
15451
+ const builder = new shared.NetworkMessageBuilder();
15452
+ builder.writeByte(shared.ClientCommand.stringcmd);
17249
15453
  const userinfo = `\\name\\${this.options.username}\\model\\${this.options.model}\\skin\\${this.options.skin}\\hand\\${this.options.hand ?? 0}\\fov\\${this.options.fov ?? 90}`;
17250
15454
  builder.writeString(`connect ${PROTOCOL_VERSION_RERELEASE} ${challenge} ${userinfo}`);
17251
15455
  this.transmit(builder.getData());
17252
15456
  }
17253
15457
  sendNew() {
17254
- const builder = new NetworkMessageBuilder();
17255
- builder.writeByte(ClientCommand.stringcmd);
15458
+ const builder = new shared.NetworkMessageBuilder();
15459
+ builder.writeByte(shared.ClientCommand.stringcmd);
17256
15460
  builder.writeString("new");
17257
15461
  this.transmit(builder.getData());
17258
15462
  }
17259
15463
  sendBegin() {
17260
- const builder = new NetworkMessageBuilder();
17261
- builder.writeByte(ClientCommand.stringcmd);
15464
+ const builder = new shared.NetworkMessageBuilder();
15465
+ builder.writeByte(shared.ClientCommand.stringcmd);
17262
15466
  builder.writeString("begin");
17263
15467
  this.transmit(builder.getData());
17264
15468
  }
@@ -17388,217 +15592,249 @@ function createEngine(imports) {
17388
15592
  }
17389
15593
  };
17390
15594
  }
17391
- // Annotate the CommonJS export names for ESM import in node:
17392
- 0 && (module.exports = {
17393
- ATTN_IDLE,
17394
- ATTN_LOOP_NONE,
17395
- ATTN_NONE,
17396
- ATTN_NORM,
17397
- ATTN_STATIC,
17398
- AssetDependencyError,
17399
- AssetDependencyTracker,
17400
- AssetManager,
17401
- AssetPreviewGenerator,
17402
- AudioApi,
17403
- AudioContextController,
17404
- AudioOcclusion,
17405
- AudioRegistry,
17406
- AudioRegistryError,
17407
- AudioSystem,
17408
- BSP_SURFACE_FRAGMENT_SOURCE,
17409
- BSP_SURFACE_VERTEX_SOURCE,
17410
- BSP_VERTEX_LAYOUT,
17411
- BspLoader,
17412
- BspParseError,
17413
- BspSurfacePipeline,
17414
- Camera,
17415
- ClientConnection,
17416
- Command,
17417
- CommandRegistry,
17418
- ConfigStringRegistry,
17419
- ConnectionState,
17420
- Cvar,
17421
- CvarRegistry,
17422
- DemoAnalyzer,
17423
- DemoCameraMode,
17424
- DemoClipper,
17425
- DemoEventType,
17426
- DemoPlaybackController,
17427
- DemoReader,
17428
- DemoRecorder,
17429
- DemoValidator,
17430
- DynamicLightManager,
17431
- EngineHost,
17432
- EngineRuntime,
17433
- FileType,
17434
- FixedTimestepLoop,
17435
- Framebuffer,
17436
- IndexBuffer,
17437
- LruCache,
17438
- MAX_SOUND_CHANNELS,
17439
- MD2_FRAGMENT_SHADER,
17440
- MD2_VERTEX_SHADER,
17441
- MD3_FRAGMENT_SHADER,
17442
- MD3_VERTEX_SHADER,
17443
- MapAnalyzer,
17444
- Md2Loader,
17445
- Md2MeshBuffers,
17446
- Md2ParseError,
17447
- Md2Pipeline,
17448
- Md3Loader,
17449
- Md3ModelMesh,
17450
- Md3ParseError,
17451
- Md3Pipeline,
17452
- Md3SurfaceMesh,
17453
- MessageWriter,
17454
- MusicSystem,
17455
- NetworkMessageParser,
17456
- PARTICLE_FRAGMENT_SHADER,
17457
- PARTICLE_VERTEX_SHADER,
17458
- PROTOCOL_VERSION_RERELEASE,
17459
- PakArchive,
17460
- PakIndexStore,
17461
- PakIngestionError,
17462
- PakParseError,
17463
- PakValidationError,
17464
- PakValidator,
17465
- PakWriter,
17466
- ParticleRenderer,
17467
- ParticleSystem,
17468
- PlaybackState,
17469
- RERELEASE_KNOWN_PAKS,
17470
- ResourceLoadTracker,
17471
- ResourceType,
17472
- SKYBOX_FRAGMENT_SHADER,
17473
- SKYBOX_VERTEX_SHADER,
17474
- SOUND_FULLVOLUME,
17475
- SOUND_LOOP_ATTENUATE,
17476
- ShaderProgram,
17477
- SkyboxPipeline,
17478
- SoundChannel,
17479
- SoundPrecache,
17480
- SoundRegistry,
17481
- SpriteLoader,
17482
- SpriteParseError,
17483
- SpriteRenderer,
17484
- StreamingPakArchive,
17485
- Texture2D,
17486
- TextureCache,
17487
- TextureCubeMap,
17488
- TgaParseError,
17489
- U_ALPHA,
17490
- U_ANGLE1,
17491
- U_ANGLE2,
17492
- U_ANGLE3,
17493
- U_EFFECTS16,
17494
- U_EFFECTS8,
17495
- U_EVENT,
17496
- U_FRAME16,
17497
- U_FRAME8,
17498
- U_INSTANCE_BITS,
17499
- U_LOOP_ATTENUATION_HIGH,
17500
- U_LOOP_VOLUME,
17501
- U_MODEL,
17502
- U_MODEL2,
17503
- U_MODEL3,
17504
- U_MODEL4,
17505
- U_OLDORIGIN,
17506
- U_OLD_FRAME_HIGH,
17507
- U_ORIGIN1,
17508
- U_ORIGIN2,
17509
- U_ORIGIN3,
17510
- U_OWNER_HIGH,
17511
- U_REMOVE,
17512
- U_RENDERFX16,
17513
- U_RENDERFX8,
17514
- U_SCALE,
17515
- U_SKIN16,
17516
- U_SKIN8,
17517
- U_SOLID,
17518
- U_SOUND,
17519
- VertexArray,
17520
- VertexBuffer,
17521
- VirtualFileSystem,
17522
- advanceAnimation,
17523
- applyEntityDelta,
17524
- applySurfaceState,
17525
- attenuationToDistanceMultiplier,
17526
- boxIntersectsFrustum,
17527
- buildBspGeometry,
17528
- buildMd2Geometry,
17529
- buildMd2VertexData,
17530
- buildMd3SurfaceGeometry,
17531
- buildMd3VertexData,
17532
- calculateMaxAudibleDistance,
17533
- calculatePakChecksum,
17534
- captureRenderTarget,
17535
- computeFrameBlend,
17536
- computeSkyScroll,
17537
- createAnimationState,
17538
- createAudioGraph,
17539
- createBspSurfaces,
17540
- createEmptyEntityState,
17541
- createEmptyProtocolPlayerState,
17542
- createEngine,
17543
- createEngineRuntime,
17544
- createFaceLightmap,
17545
- createHeadlessRenderTarget,
17546
- createInitialChannels,
17547
- createOcclusionResolver,
17548
- createProgramFromSources,
17549
- createWebGLContext,
17550
- createWebGPUContext,
17551
- decodeOgg,
17552
- deriveSurfaceRenderState,
17553
- detectFileType,
17554
- extractFrustumPlanes,
17555
- filesToPakSources,
17556
- findLeafForPoint,
17557
- gatherVisibleFaces,
17558
- groupMd2Animations,
17559
- ingestPakFiles,
17560
- ingestPaks,
17561
- interpolateMd3Tag,
17562
- interpolateVec3,
17563
- isBinaryFile,
17564
- isTextFile,
17565
- parseBsp,
17566
- parseEntLump,
17567
- parseMd2,
17568
- parseMd3,
17569
- parsePcx,
17570
- parseSprite,
17571
- parseTga,
17572
- parseWal,
17573
- parseWalTexture,
17574
- parseWav,
17575
- pcxToRgba,
17576
- pickChannel,
17577
- preparePcxTexture,
17578
- queryCapabilities,
17579
- removeViewTranslation,
17580
- resolveLightStyles,
17581
- serializeEntLump,
17582
- spawnBfgExplosion,
17583
- spawnBlasterImpact,
17584
- spawnBlood,
17585
- spawnBulletImpact,
17586
- spawnExplosion,
17587
- spawnMuzzleFlash,
17588
- spawnRailTrail,
17589
- spawnSparks,
17590
- spawnSplash,
17591
- spawnSteam,
17592
- spawnTeleportFlash,
17593
- spawnTrail,
17594
- validateEntity,
17595
- walToRgba,
17596
- wireDropTarget,
17597
- wireFileInput
17598
- });
17599
15595
  /*! Bundled license information:
17600
15596
 
17601
15597
  pako/dist/pako.esm.mjs:
17602
15598
  (*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *)
17603
15599
  */
15600
+
15601
+ Object.defineProperty(exports, "ATTN_IDLE", {
15602
+ enumerable: true,
15603
+ get: function () { return shared.ATTN_IDLE; }
15604
+ });
15605
+ Object.defineProperty(exports, "ATTN_LOOP_NONE", {
15606
+ enumerable: true,
15607
+ get: function () { return shared.ATTN_LOOP_NONE; }
15608
+ });
15609
+ Object.defineProperty(exports, "ATTN_NONE", {
15610
+ enumerable: true,
15611
+ get: function () { return shared.ATTN_NONE; }
15612
+ });
15613
+ Object.defineProperty(exports, "ATTN_NORM", {
15614
+ enumerable: true,
15615
+ get: function () { return shared.ATTN_NORM; }
15616
+ });
15617
+ Object.defineProperty(exports, "ATTN_STATIC", {
15618
+ enumerable: true,
15619
+ get: function () { return shared.ATTN_STATIC; }
15620
+ });
15621
+ Object.defineProperty(exports, "MAX_SOUND_CHANNELS", {
15622
+ enumerable: true,
15623
+ get: function () { return shared.MAX_SOUND_CHANNELS; }
15624
+ });
15625
+ Object.defineProperty(exports, "SOUND_FULLVOLUME", {
15626
+ enumerable: true,
15627
+ get: function () { return shared.SOUND_FULLVOLUME; }
15628
+ });
15629
+ Object.defineProperty(exports, "SOUND_LOOP_ATTENUATE", {
15630
+ enumerable: true,
15631
+ get: function () { return shared.SOUND_LOOP_ATTENUATE; }
15632
+ });
15633
+ Object.defineProperty(exports, "SoundChannel", {
15634
+ enumerable: true,
15635
+ get: function () { return shared.SoundChannel; }
15636
+ });
15637
+ Object.defineProperty(exports, "attenuationToDistanceMultiplier", {
15638
+ enumerable: true,
15639
+ get: function () { return shared.attenuationToDistanceMultiplier; }
15640
+ });
15641
+ Object.defineProperty(exports, "calculateMaxAudibleDistance", {
15642
+ enumerable: true,
15643
+ get: function () { return shared.calculateMaxAudibleDistance; }
15644
+ });
15645
+ exports.AssetDependencyError = AssetDependencyError;
15646
+ exports.AssetDependencyTracker = AssetDependencyTracker;
15647
+ exports.AssetManager = AssetManager;
15648
+ exports.AssetPreviewGenerator = AssetPreviewGenerator;
15649
+ exports.AudioApi = AudioApi;
15650
+ exports.AudioContextController = AudioContextController;
15651
+ exports.AudioOcclusion = AudioOcclusion;
15652
+ exports.AudioRegistry = AudioRegistry;
15653
+ exports.AudioRegistryError = AudioRegistryError;
15654
+ exports.AudioSystem = AudioSystem;
15655
+ exports.BSP_SURFACE_FRAGMENT_SOURCE = BSP_SURFACE_FRAGMENT_SOURCE;
15656
+ exports.BSP_SURFACE_VERTEX_SOURCE = BSP_SURFACE_VERTEX_SOURCE;
15657
+ exports.BSP_VERTEX_LAYOUT = BSP_VERTEX_LAYOUT;
15658
+ exports.BspLoader = BspLoader;
15659
+ exports.BspParseError = BspParseError;
15660
+ exports.BspSurfacePipeline = BspSurfacePipeline;
15661
+ exports.Camera = Camera;
15662
+ exports.ClientConnection = ClientConnection;
15663
+ exports.Command = Command;
15664
+ exports.CommandRegistry = CommandRegistry;
15665
+ exports.ConfigStringRegistry = ConfigStringRegistry;
15666
+ exports.ConnectionState = ConnectionState;
15667
+ exports.Cvar = Cvar;
15668
+ exports.CvarRegistry = CvarRegistry;
15669
+ exports.DemoAnalyzer = DemoAnalyzer;
15670
+ exports.DemoCameraMode = DemoCameraMode;
15671
+ exports.DemoClipper = DemoClipper;
15672
+ exports.DemoEventType = DemoEventType;
15673
+ exports.DemoPlaybackController = DemoPlaybackController;
15674
+ exports.DemoReader = DemoReader;
15675
+ exports.DemoRecorder = DemoRecorder;
15676
+ exports.DemoValidator = DemoValidator;
15677
+ exports.DynamicLightManager = DynamicLightManager;
15678
+ exports.EngineHost = EngineHost;
15679
+ exports.EngineRuntime = EngineRuntime;
15680
+ exports.FileType = FileType;
15681
+ exports.FixedTimestepLoop = FixedTimestepLoop;
15682
+ exports.Framebuffer = Framebuffer;
15683
+ exports.IndexBuffer = IndexBuffer;
15684
+ exports.LruCache = LruCache;
15685
+ exports.MD2_FRAGMENT_SHADER = MD2_FRAGMENT_SHADER;
15686
+ exports.MD2_VERTEX_SHADER = MD2_VERTEX_SHADER;
15687
+ exports.MD3_FRAGMENT_SHADER = MD3_FRAGMENT_SHADER;
15688
+ exports.MD3_VERTEX_SHADER = MD3_VERTEX_SHADER;
15689
+ exports.MapAnalyzer = MapAnalyzer;
15690
+ exports.Md2Loader = Md2Loader;
15691
+ exports.Md2MeshBuffers = Md2MeshBuffers;
15692
+ exports.Md2ParseError = Md2ParseError;
15693
+ exports.Md2Pipeline = Md2Pipeline;
15694
+ exports.Md3Loader = Md3Loader;
15695
+ exports.Md3ModelMesh = Md3ModelMesh;
15696
+ exports.Md3ParseError = Md3ParseError;
15697
+ exports.Md3Pipeline = Md3Pipeline;
15698
+ exports.Md3SurfaceMesh = Md3SurfaceMesh;
15699
+ exports.MessageWriter = MessageWriter;
15700
+ exports.MusicSystem = MusicSystem;
15701
+ exports.NetworkMessageParser = NetworkMessageParser;
15702
+ exports.PARTICLE_FRAGMENT_SHADER = PARTICLE_FRAGMENT_SHADER;
15703
+ exports.PARTICLE_VERTEX_SHADER = PARTICLE_VERTEX_SHADER;
15704
+ exports.PROTOCOL_VERSION_RERELEASE = PROTOCOL_VERSION_RERELEASE;
15705
+ exports.PakArchive = PakArchive;
15706
+ exports.PakIndexStore = PakIndexStore;
15707
+ exports.PakIngestionError = PakIngestionError;
15708
+ exports.PakParseError = PakParseError;
15709
+ exports.PakValidationError = PakValidationError;
15710
+ exports.PakValidator = PakValidator;
15711
+ exports.PakWriter = PakWriter;
15712
+ exports.ParticleRenderer = ParticleRenderer;
15713
+ exports.ParticleSystem = ParticleSystem;
15714
+ exports.PlaybackState = PlaybackState;
15715
+ exports.RERELEASE_KNOWN_PAKS = RERELEASE_KNOWN_PAKS;
15716
+ exports.ResourceLoadTracker = ResourceLoadTracker;
15717
+ exports.ResourceType = ResourceType;
15718
+ exports.SKYBOX_FRAGMENT_SHADER = SKYBOX_FRAGMENT_SHADER;
15719
+ exports.SKYBOX_VERTEX_SHADER = SKYBOX_VERTEX_SHADER;
15720
+ exports.ShaderProgram = ShaderProgram;
15721
+ exports.SkyboxPipeline = SkyboxPipeline;
15722
+ exports.SoundPrecache = SoundPrecache;
15723
+ exports.SoundRegistry = SoundRegistry;
15724
+ exports.SpriteLoader = SpriteLoader;
15725
+ exports.SpriteParseError = SpriteParseError;
15726
+ exports.SpriteRenderer = SpriteRenderer;
15727
+ exports.StreamingPakArchive = StreamingPakArchive;
15728
+ exports.Texture2D = Texture2D;
15729
+ exports.TextureCache = TextureCache;
15730
+ exports.TextureCubeMap = TextureCubeMap;
15731
+ exports.TgaParseError = TgaParseError;
15732
+ exports.U_ALPHA = U_ALPHA;
15733
+ exports.U_ANGLE1 = U_ANGLE1;
15734
+ exports.U_ANGLE2 = U_ANGLE2;
15735
+ exports.U_ANGLE3 = U_ANGLE3;
15736
+ exports.U_EFFECTS16 = U_EFFECTS16;
15737
+ exports.U_EFFECTS8 = U_EFFECTS8;
15738
+ exports.U_EVENT = U_EVENT;
15739
+ exports.U_FRAME16 = U_FRAME16;
15740
+ exports.U_FRAME8 = U_FRAME8;
15741
+ exports.U_INSTANCE_BITS = U_INSTANCE_BITS;
15742
+ exports.U_LOOP_ATTENUATION_HIGH = U_LOOP_ATTENUATION_HIGH;
15743
+ exports.U_LOOP_VOLUME = U_LOOP_VOLUME;
15744
+ exports.U_MODEL = U_MODEL;
15745
+ exports.U_MODEL2 = U_MODEL2;
15746
+ exports.U_MODEL3 = U_MODEL3;
15747
+ exports.U_MODEL4 = U_MODEL4;
15748
+ exports.U_OLDORIGIN = U_OLDORIGIN;
15749
+ exports.U_OLD_FRAME_HIGH = U_OLD_FRAME_HIGH;
15750
+ exports.U_ORIGIN1 = U_ORIGIN1;
15751
+ exports.U_ORIGIN2 = U_ORIGIN2;
15752
+ exports.U_ORIGIN3 = U_ORIGIN3;
15753
+ exports.U_OWNER_HIGH = U_OWNER_HIGH;
15754
+ exports.U_REMOVE = U_REMOVE;
15755
+ exports.U_RENDERFX16 = U_RENDERFX16;
15756
+ exports.U_RENDERFX8 = U_RENDERFX8;
15757
+ exports.U_SCALE = U_SCALE;
15758
+ exports.U_SKIN16 = U_SKIN16;
15759
+ exports.U_SKIN8 = U_SKIN8;
15760
+ exports.U_SOLID = U_SOLID;
15761
+ exports.U_SOUND = U_SOUND;
15762
+ exports.VertexArray = VertexArray;
15763
+ exports.VertexBuffer = VertexBuffer;
15764
+ exports.VirtualFileSystem = VirtualFileSystem;
15765
+ exports.advanceAnimation = advanceAnimation;
15766
+ exports.applyEntityDelta = applyEntityDelta;
15767
+ exports.applySurfaceState = applySurfaceState;
15768
+ exports.boxIntersectsFrustum = boxIntersectsFrustum;
15769
+ exports.buildBspGeometry = buildBspGeometry;
15770
+ exports.buildMd2Geometry = buildMd2Geometry;
15771
+ exports.buildMd2VertexData = buildMd2VertexData;
15772
+ exports.buildMd3SurfaceGeometry = buildMd3SurfaceGeometry;
15773
+ exports.buildMd3VertexData = buildMd3VertexData;
15774
+ exports.calculatePakChecksum = calculatePakChecksum;
15775
+ exports.captureRenderTarget = captureRenderTarget;
15776
+ exports.computeFrameBlend = computeFrameBlend;
15777
+ exports.computeSkyScroll = computeSkyScroll;
15778
+ exports.createAnimationState = createAnimationState;
15779
+ exports.createAudioGraph = createAudioGraph;
15780
+ exports.createBspSurfaces = createBspSurfaces;
15781
+ exports.createEmptyEntityState = createEmptyEntityState;
15782
+ exports.createEmptyProtocolPlayerState = createEmptyProtocolPlayerState;
15783
+ exports.createEngine = createEngine;
15784
+ exports.createEngineRuntime = createEngineRuntime;
15785
+ exports.createFaceLightmap = createFaceLightmap;
15786
+ exports.createHeadlessRenderTarget = createHeadlessRenderTarget;
15787
+ exports.createInitialChannels = createInitialChannels;
15788
+ exports.createOcclusionResolver = createOcclusionResolver;
15789
+ exports.createProgramFromSources = createProgramFromSources;
15790
+ exports.createWebGLContext = createWebGLContext;
15791
+ exports.createWebGPUContext = createWebGPUContext;
15792
+ exports.decodeOgg = decodeOgg;
15793
+ exports.deriveSurfaceRenderState = deriveSurfaceRenderState;
15794
+ exports.detectFileType = detectFileType;
15795
+ exports.extractFrustumPlanes = extractFrustumPlanes;
15796
+ exports.filesToPakSources = filesToPakSources;
15797
+ exports.findLeafForPoint = findLeafForPoint;
15798
+ exports.gatherVisibleFaces = gatherVisibleFaces;
15799
+ exports.groupMd2Animations = groupMd2Animations;
15800
+ exports.ingestPakFiles = ingestPakFiles;
15801
+ exports.ingestPaks = ingestPaks;
15802
+ exports.interpolateMd3Tag = interpolateMd3Tag;
15803
+ exports.interpolateVec3 = interpolateVec3;
15804
+ exports.isBinaryFile = isBinaryFile;
15805
+ exports.isTextFile = isTextFile;
15806
+ exports.parseBsp = parseBsp;
15807
+ exports.parseEntLump = parseEntLump;
15808
+ exports.parseMd2 = parseMd2;
15809
+ exports.parseMd3 = parseMd3;
15810
+ exports.parsePcx = parsePcx;
15811
+ exports.parseSprite = parseSprite;
15812
+ exports.parseTga = parseTga;
15813
+ exports.parseWal = parseWal;
15814
+ exports.parseWalTexture = parseWalTexture;
15815
+ exports.parseWav = parseWav;
15816
+ exports.pcxToRgba = pcxToRgba;
15817
+ exports.pickChannel = pickChannel;
15818
+ exports.preparePcxTexture = preparePcxTexture;
15819
+ exports.queryCapabilities = queryCapabilities;
15820
+ exports.removeViewTranslation = removeViewTranslation;
15821
+ exports.resolveLightStyles = resolveLightStyles;
15822
+ exports.serializeEntLump = serializeEntLump;
15823
+ exports.spawnBfgExplosion = spawnBfgExplosion;
15824
+ exports.spawnBlasterImpact = spawnBlasterImpact;
15825
+ exports.spawnBlood = spawnBlood;
15826
+ exports.spawnBulletImpact = spawnBulletImpact;
15827
+ exports.spawnExplosion = spawnExplosion;
15828
+ exports.spawnMuzzleFlash = spawnMuzzleFlash;
15829
+ exports.spawnRailTrail = spawnRailTrail;
15830
+ exports.spawnSparks = spawnSparks;
15831
+ exports.spawnSplash = spawnSplash;
15832
+ exports.spawnSteam = spawnSteam;
15833
+ exports.spawnTeleportFlash = spawnTeleportFlash;
15834
+ exports.spawnTrail = spawnTrail;
15835
+ exports.validateEntity = validateEntity;
15836
+ exports.walToRgba = walToRgba;
15837
+ exports.wireDropTarget = wireDropTarget;
15838
+ exports.wireFileInput = wireFileInput;
15839
+ //# sourceMappingURL=index.cjs.map
17604
15840
  //# sourceMappingURL=index.cjs.map