@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.
package/dist/esm/index.js CHANGED
@@ -1,3 +1,8 @@
1
+ import { ServerCommand, SURF_NONE, CvarFlags, ConfigStringIndex, MAX_CONFIGSTRINGS, MAX_MODELS, MAX_SOUNDS, MAX_IMAGES, MAX_LIGHTSTYLES, MAX_SHADOW_LIGHTS, MAX_ITEMS, MAX_CLIENTS, MAX_GENERAL, MAX_SOUND_CHANNELS, SoundChannel, ZERO_VEC3, ATTN_NONE, attenuationToDistanceMultiplier, SOUND_FULLVOLUME, calculateMaxAudibleDistance, lengthVec3, subtractVec3, RAD2DEG, DEG2RAD, normalizeVec3 as normalizeVec3$1, mat4FromBasis, BinaryStream, ANORMS, TempEntity, BinaryWriter, NetChan, crc8, CMD_BACKUP, ClientCommand, writeUserCommand, NetworkMessageBuilder, SURF_FLOWING, SURF_WARP, SURF_SKY, SURF_TRANS33, SURF_TRANS66, configStringSize, CS_MAX_STRING_LENGTH, transformPointMat4 } from '@quake2ts/shared';
2
+ export { ATTN_IDLE, ATTN_LOOP_NONE, ATTN_NONE, ATTN_NORM, ATTN_STATIC, MAX_SOUND_CHANNELS, SOUND_FULLVOLUME, SOUND_LOOP_ATTENUATE, SoundChannel, attenuationToDistanceMultiplier, calculateMaxAudibleDistance } from '@quake2ts/shared';
3
+ import { OggVorbisDecoder } from '@wasm-audio-decoders/ogg-vorbis';
4
+ import { vec3, mat4 } from 'gl-matrix';
5
+
1
6
  // src/loop.ts
2
7
  var DEFAULT_FIXED_DELTA_MS = 25;
3
8
  var DEFAULT_MAX_SUBSTEPS = 5;
@@ -180,1526 +185,6 @@ var CommandRegistry = class {
180
185
  return [...this.commands.values()].sort((a, b) => a.name.localeCompare(b.name));
181
186
  }
182
187
  };
183
-
184
- // ../shared/dist/esm/index.js
185
- var __defProp = Object.defineProperty;
186
- var __export = (target, all) => {
187
- for (var name in all)
188
- __defProp(target, name, { get: all[name], enumerable: true });
189
- };
190
- var ZERO_VEC3 = { x: 0, y: 0, z: 0 };
191
- var DEG_TO_RAD = Math.PI / 180;
192
- function subtractVec3(a, b) {
193
- return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
194
- }
195
- function scaleVec3(a, scalar) {
196
- return { x: a.x * scalar, y: a.y * scalar, z: a.z * scalar };
197
- }
198
- function dotVec3(a, b) {
199
- return a.x * b.x + a.y * b.y + a.z * b.z;
200
- }
201
- function lengthSquaredVec3(a) {
202
- return dotVec3(a, a);
203
- }
204
- function lengthVec3(a) {
205
- return Math.sqrt(lengthSquaredVec3(a));
206
- }
207
- function normalizeVec3(a) {
208
- const len = lengthVec3(a);
209
- return len === 0 ? a : scaleVec3(a, 1 / len);
210
- }
211
- var DEG2RAD_FACTOR = Math.PI / 180;
212
- var RAD2DEG_FACTOR = 180 / Math.PI;
213
- var DEG2RAD = DEG2RAD_FACTOR;
214
- var RAD2DEG = RAD2DEG_FACTOR;
215
- var ANORMS = [
216
- [-0.525731, 0, 0.850651],
217
- [-0.442863, 0.238856, 0.864188],
218
- [-0.295242, 0, 0.955423],
219
- [-0.309017, 0.5, 0.809017],
220
- [-0.16246, 0.262866, 0.951056],
221
- [0, 0, 1],
222
- [0, 0.850651, 0.525731],
223
- [-0.147621, 0.716567, 0.681718],
224
- [0.147621, 0.716567, 0.681718],
225
- [0, 0.525731, 0.850651],
226
- [0.309017, 0.5, 0.809017],
227
- [0.525731, 0, 0.850651],
228
- [0.295242, 0, 0.955423],
229
- [0.442863, 0.238856, 0.864188],
230
- [0.16246, 0.262866, 0.951056],
231
- [-0.681718, 0.147621, 0.716567],
232
- [-0.809017, 0.309017, 0.5],
233
- [-0.587785, 0.425325, 0.688191],
234
- [-0.850651, 0.525731, 0],
235
- [-0.864188, 0.442863, 0.238856],
236
- [-0.716567, 0.681718, 0.147621],
237
- [-0.688191, 0.587785, 0.425325],
238
- [-0.5, 0.809017, 0.309017],
239
- [-0.238856, 0.864188, 0.442863],
240
- [-0.425325, 0.688191, 0.587785],
241
- [-0.716567, 0.681718, -0.147621],
242
- [-0.5, 0.809017, -0.309017],
243
- [-0.525731, 0.850651, 0],
244
- [0, 0.850651, -0.525731],
245
- [-0.238856, 0.864188, -0.442863],
246
- [0, 0.955423, -0.295242],
247
- [-0.262866, 0.951056, -0.16246],
248
- [0, 1, 0],
249
- [0, 0.955423, 0.295242],
250
- [-0.262866, 0.951056, 0.16246],
251
- [0.238856, 0.864188, 0.442863],
252
- [0.262866, 0.951056, 0.16246],
253
- [0.5, 0.809017, 0.309017],
254
- [0.238856, 0.864188, -0.442863],
255
- [0.262866, 0.951056, -0.16246],
256
- [0.5, 0.809017, -0.309017],
257
- [0.850651, 0.525731, 0],
258
- [0.716567, 0.681718, 0.147621],
259
- [0.716567, 0.681718, -0.147621],
260
- [0.525731, 0.850651, 0],
261
- [0.425325, 0.688191, 0.587785],
262
- [0.864188, 0.442863, 0.238856],
263
- [0.688191, 0.587785, 0.425325],
264
- [0.809017, 0.309017, 0.5],
265
- [0.681718, 0.147621, 0.716567],
266
- [0.587785, 0.425325, 0.688191],
267
- [0.955423, 0.295242, 0],
268
- [1, 0, 0],
269
- [0.951056, 0.16246, 0.262866],
270
- [0.850651, -0.525731, 0],
271
- [0.955423, -0.295242, 0],
272
- [0.864188, -0.442863, 0.238856],
273
- [0.951056, -0.16246, 0.262866],
274
- [0.809017, -0.309017, 0.5],
275
- [0.681718, -0.147621, 0.716567],
276
- [0.850651, 0, 0.525731],
277
- [0.864188, 0.442863, -0.238856],
278
- [0.809017, 0.309017, -0.5],
279
- [0.951056, 0.16246, -0.262866],
280
- [0.525731, 0, -0.850651],
281
- [0.681718, 0.147621, -0.716567],
282
- [0.681718, -0.147621, -0.716567],
283
- [0.850651, 0, -0.525731],
284
- [0.809017, -0.309017, -0.5],
285
- [0.864188, -0.442863, -0.238856],
286
- [0.951056, -0.16246, -0.262866],
287
- [0.147621, 0.716567, -0.681718],
288
- [0.309017, 0.5, -0.809017],
289
- [0.425325, 0.688191, -0.587785],
290
- [0.442863, 0.238856, -0.864188],
291
- [0.587785, 0.425325, -0.688191],
292
- [0.688191, 0.587785, -0.425325],
293
- [-0.147621, 0.716567, -0.681718],
294
- [-0.309017, 0.5, -0.809017],
295
- [0, 0.525731, -0.850651],
296
- [-0.525731, 0, -0.850651],
297
- [-0.442863, 0.238856, -0.864188],
298
- [-0.295242, 0, -0.955423],
299
- [-0.16246, 0.262866, -0.951056],
300
- [0, 0, -1],
301
- [0.295242, 0, -0.955423],
302
- [0.16246, 0.262866, -0.951056],
303
- [-0.442863, -0.238856, -0.864188],
304
- [-0.309017, -0.5, -0.809017],
305
- [-0.16246, -0.262866, -0.951056],
306
- [0, -0.850651, -0.525731],
307
- [-0.147621, -0.716567, -0.681718],
308
- [0.147621, -0.716567, -0.681718],
309
- [0, -0.525731, -0.850651],
310
- [0.309017, -0.5, -0.809017],
311
- [0.442863, -0.238856, -0.864188],
312
- [0.16246, -0.262866, -0.951056],
313
- [0.238856, -0.864188, -0.442863],
314
- [0.5, -0.809017, -0.309017],
315
- [0.425325, -0.688191, -0.587785],
316
- [0.716567, -0.681718, -0.147621],
317
- [0.688191, -0.587785, -0.425325],
318
- [0.587785, -0.425325, -0.688191],
319
- [0, -0.955423, -0.295242],
320
- [0, -1, 0],
321
- [0.262866, -0.951056, -0.16246],
322
- [0, -0.850651, 0.525731],
323
- [0, -0.955423, 0.295242],
324
- [0.238856, -0.864188, 0.442863],
325
- [0.262866, -0.951056, 0.16246],
326
- [0.5, -0.809017, 0.309017],
327
- [0.716567, -0.681718, 0.147621],
328
- [0.525731, -0.850651, 0],
329
- [-0.238856, -0.864188, -0.442863],
330
- [-0.5, -0.809017, -0.309017],
331
- [-0.262866, -0.951056, -0.16246],
332
- [-0.850651, -0.525731, 0],
333
- [-0.716567, -0.681718, -0.147621],
334
- [-0.716567, -0.681718, 0.147621],
335
- [-0.525731, -0.850651, 0],
336
- [-0.5, -0.809017, 0.309017],
337
- [-0.238856, -0.864188, 0.442863],
338
- [-0.262866, -0.951056, 0.16246],
339
- [-0.864188, -0.442863, 0.238856],
340
- [-0.809017, -0.309017, 0.5],
341
- [-0.688191, -0.587785, 0.425325],
342
- [-0.681718, -0.147621, 0.716567],
343
- [-0.442863, -0.238856, 0.864188],
344
- [-0.587785, -0.425325, 0.688191],
345
- [-0.309017, -0.5, 0.809017],
346
- [-0.147621, -0.716567, 0.681718],
347
- [-0.425325, -0.688191, 0.587785],
348
- [-0.16246, -0.262866, 0.951056],
349
- [0.442863, -0.238856, 0.864188],
350
- [0.16246, -0.262866, 0.951056],
351
- [0.309017, -0.5, 0.809017],
352
- [0.147621, -0.716567, 0.681718],
353
- [0, -0.525731, 0.850651],
354
- [0.425325, -0.688191, 0.587785],
355
- [0.587785, -0.425325, 0.688191],
356
- [0.688191, -0.587785, 0.425325],
357
- [-0.955423, 0.295242, 0],
358
- [-0.951056, 0.16246, 0.262866],
359
- [-1, 0, 0],
360
- [-0.850651, 0, 0.525731],
361
- [-0.955423, -0.295242, 0],
362
- [-0.951056, -0.16246, 0.262866],
363
- [-0.864188, 0.442863, -0.238856],
364
- [-0.951056, 0.16246, -0.262866],
365
- [-0.809017, 0.309017, -0.5],
366
- [-0.864188, -0.442863, -0.238856],
367
- [-0.951056, -0.16246, -0.262866],
368
- [-0.809017, -0.309017, -0.5],
369
- [-0.681718, 0.147621, -0.716567],
370
- [-0.681718, -0.147621, -0.716567],
371
- [-0.850651, 0, -0.525731],
372
- [-0.688191, 0.587785, -0.425325],
373
- [-0.587785, 0.425325, -0.688191],
374
- [-0.425325, 0.688191, -0.587785],
375
- [-0.425325, -0.688191, -0.587785],
376
- [-0.587785, -0.425325, -0.688191],
377
- [-0.688191, -0.587785, -0.425325]
378
- ];
379
- function createMat4Identity() {
380
- return new Float32Array([
381
- 1,
382
- 0,
383
- 0,
384
- 0,
385
- 0,
386
- 1,
387
- 0,
388
- 0,
389
- 0,
390
- 0,
391
- 1,
392
- 0,
393
- 0,
394
- 0,
395
- 0,
396
- 1
397
- ]);
398
- }
399
- function transformPointMat4(mat, point) {
400
- const x = point.x;
401
- const y = point.y;
402
- const z = point.z;
403
- return {
404
- x: mat[0] * x + mat[4] * y + mat[8] * z + mat[12],
405
- y: mat[1] * x + mat[5] * y + mat[9] * z + mat[13],
406
- z: mat[2] * x + mat[6] * y + mat[10] * z + mat[14]
407
- };
408
- }
409
- function mat4FromBasis(origin, axis) {
410
- const out = createMat4Identity();
411
- out[0] = axis[0].x;
412
- out[1] = axis[0].y;
413
- out[2] = axis[0].z;
414
- out[4] = axis[1].x;
415
- out[5] = axis[1].y;
416
- out[6] = axis[1].z;
417
- out[8] = axis[2].x;
418
- out[9] = axis[2].y;
419
- out[10] = axis[2].z;
420
- out[12] = origin.x;
421
- out[13] = origin.y;
422
- out[14] = origin.z;
423
- return out;
424
- }
425
- var CONTENTS_SOLID = 1 << 0;
426
- var CONTENTS_WINDOW = 1 << 1;
427
- var CONTENTS_AUX = 1 << 2;
428
- var CONTENTS_LAVA = 1 << 3;
429
- var CONTENTS_SLIME = 1 << 4;
430
- var CONTENTS_WATER = 1 << 5;
431
- var CONTENTS_MIST = 1 << 6;
432
- var CONTENTS_NO_WATERJUMP = 1 << 13;
433
- var CONTENTS_PROJECTILECLIP = 1 << 14;
434
- var CONTENTS_AREAPORTAL = 1 << 15;
435
- var CONTENTS_PLAYERCLIP = 1 << 16;
436
- var CONTENTS_MONSTERCLIP = 1 << 17;
437
- var CONTENTS_CURRENT_0 = 1 << 18;
438
- var CONTENTS_CURRENT_90 = 1 << 19;
439
- var CONTENTS_CURRENT_180 = 1 << 20;
440
- var CONTENTS_CURRENT_270 = 1 << 21;
441
- var CONTENTS_CURRENT_UP = 1 << 22;
442
- var CONTENTS_CURRENT_DOWN = 1 << 23;
443
- var CONTENTS_ORIGIN = 1 << 24;
444
- var CONTENTS_MONSTER = 1 << 25;
445
- var CONTENTS_DEADMONSTER = 1 << 26;
446
- var CONTENTS_DETAIL = 1 << 27;
447
- var CONTENTS_TRANSLUCENT = 1 << 28;
448
- var CONTENTS_LADDER = 1 << 29;
449
- var CONTENTS_PLAYER = 1 << 30;
450
- var CONTENTS_PROJECTILE = 1 << 31;
451
- var SURF_NONE = 0;
452
- var SURF_LIGHT = 1 << 0;
453
- var SURF_SLICK = 1 << 1;
454
- var SURF_SKY = 1 << 2;
455
- var SURF_WARP = 1 << 3;
456
- var SURF_TRANS33 = 1 << 4;
457
- var SURF_TRANS66 = 1 << 5;
458
- var SURF_FLOWING = 1 << 6;
459
- var SURF_NODRAW = 1 << 7;
460
- var SURF_ALPHATEST = 1 << 25;
461
- var SURF_N64_UV = 1 << 28;
462
- var SURF_N64_SCROLL_X = 1 << 29;
463
- var SURF_N64_SCROLL_Y = 1 << 30;
464
- var SURF_N64_SCROLL_FLIP = 1 << 31;
465
- var MASK_SOLID = CONTENTS_SOLID | CONTENTS_WINDOW;
466
- var MASK_PLAYERSOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_PLAYER;
467
- var MASK_DEADSOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW;
468
- var MASK_MONSTERSOLID = CONTENTS_SOLID | CONTENTS_MONSTERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_PLAYER;
469
- var MASK_WATER = CONTENTS_WATER | CONTENTS_LAVA | CONTENTS_SLIME;
470
- var MASK_OPAQUE = CONTENTS_SOLID | CONTENTS_SLIME | CONTENTS_LAVA;
471
- var MASK_SHOT = CONTENTS_SOLID | CONTENTS_MONSTER | CONTENTS_PLAYER | CONTENTS_WINDOW | CONTENTS_DEADMONSTER;
472
- var MASK_CURRENT = CONTENTS_CURRENT_0 | CONTENTS_CURRENT_90 | CONTENTS_CURRENT_180 | CONTENTS_CURRENT_270 | CONTENTS_CURRENT_UP | CONTENTS_CURRENT_DOWN;
473
- var MASK_BLOCK_SIGHT = CONTENTS_SOLID | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_MONSTER | CONTENTS_PLAYER;
474
- var MASK_NAV_SOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW;
475
- var MASK_LADDER_NAV_SOLID = CONTENTS_SOLID | CONTENTS_WINDOW;
476
- var MASK_WALK_NAV_SOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP;
477
- var MASK_PROJECTILE = MASK_SHOT | CONTENTS_PROJECTILECLIP;
478
- var MAX_CHECKCOUNT = Number.MAX_SAFE_INTEGER - 1;
479
- var CvarFlags = /* @__PURE__ */ ((CvarFlags2) => {
480
- CvarFlags2[CvarFlags2["None"] = 0] = "None";
481
- CvarFlags2[CvarFlags2["Archive"] = 1] = "Archive";
482
- CvarFlags2[CvarFlags2["UserInfo"] = 2] = "UserInfo";
483
- CvarFlags2[CvarFlags2["ServerInfo"] = 4] = "ServerInfo";
484
- CvarFlags2[CvarFlags2["Latch"] = 8] = "Latch";
485
- CvarFlags2[CvarFlags2["Cheat"] = 16] = "Cheat";
486
- return CvarFlags2;
487
- })(CvarFlags || {});
488
- var MAX_CLIENTS = 256;
489
- var MAX_LIGHTSTYLES = 256;
490
- var MAX_MODELS = 8192;
491
- var MAX_SOUNDS = 2048;
492
- var MAX_IMAGES = 512;
493
- var MAX_ITEMS = 256;
494
- var MAX_GENERAL = MAX_CLIENTS * 2;
495
- var MAX_SHADOW_LIGHTS = 256;
496
- var MAX_WHEEL_ITEMS = 32;
497
- var CS_MAX_STRING_LENGTH = 96;
498
- var ConfigStringIndex = ((ConfigStringIndex2) => {
499
- ConfigStringIndex2[ConfigStringIndex2["Name"] = 0] = "Name";
500
- ConfigStringIndex2[ConfigStringIndex2["CdTrack"] = 1] = "CdTrack";
501
- ConfigStringIndex2[ConfigStringIndex2["Sky"] = 2] = "Sky";
502
- ConfigStringIndex2[ConfigStringIndex2["SkyAxis"] = 3] = "SkyAxis";
503
- ConfigStringIndex2[ConfigStringIndex2["SkyRotate"] = 4] = "SkyRotate";
504
- ConfigStringIndex2[ConfigStringIndex2["StatusBar"] = 5] = "StatusBar";
505
- ConfigStringIndex2[ConfigStringIndex2["HealthBarName"] = 55] = "HealthBarName";
506
- ConfigStringIndex2[ConfigStringIndex2["CONFIG_N64_PHYSICS"] = 56] = "CONFIG_N64_PHYSICS";
507
- ConfigStringIndex2[ConfigStringIndex2["CONFIG_CTF_TEAMS"] = 57] = "CONFIG_CTF_TEAMS";
508
- ConfigStringIndex2[ConfigStringIndex2["CONFIG_COOP_RESPAWN_STRING"] = 58] = "CONFIG_COOP_RESPAWN_STRING";
509
- ConfigStringIndex2[ConfigStringIndex2["Story"] = 54] = "Story";
510
- ConfigStringIndex2[ConfigStringIndex2["AirAccel"] = 59] = "AirAccel";
511
- ConfigStringIndex2[ConfigStringIndex2["MaxClients"] = 60] = "MaxClients";
512
- ConfigStringIndex2[ConfigStringIndex2["MapChecksum"] = 61] = "MapChecksum";
513
- ConfigStringIndex2[ConfigStringIndex2["Models"] = 62] = "Models";
514
- ConfigStringIndex2[ConfigStringIndex2["Sounds"] = 62 + MAX_MODELS] = "Sounds";
515
- ConfigStringIndex2[ConfigStringIndex2["Images"] = ConfigStringIndex2.Sounds + MAX_SOUNDS] = "Images";
516
- ConfigStringIndex2[ConfigStringIndex2["Lights"] = ConfigStringIndex2.Images + MAX_IMAGES] = "Lights";
517
- ConfigStringIndex2[ConfigStringIndex2["ShadowLights"] = ConfigStringIndex2.Lights + MAX_LIGHTSTYLES] = "ShadowLights";
518
- ConfigStringIndex2[ConfigStringIndex2["Items"] = ConfigStringIndex2.ShadowLights + MAX_SHADOW_LIGHTS] = "Items";
519
- ConfigStringIndex2[ConfigStringIndex2["Players"] = ConfigStringIndex2.Items + MAX_ITEMS] = "Players";
520
- ConfigStringIndex2[ConfigStringIndex2["PlayerSkins"] = ConfigStringIndex2.Players] = "PlayerSkins";
521
- ConfigStringIndex2[ConfigStringIndex2["General"] = ConfigStringIndex2.Players + MAX_CLIENTS] = "General";
522
- ConfigStringIndex2[ConfigStringIndex2["WheelWeapons"] = ConfigStringIndex2.General + MAX_GENERAL] = "WheelWeapons";
523
- ConfigStringIndex2[ConfigStringIndex2["WheelAmmo"] = ConfigStringIndex2.WheelWeapons + MAX_WHEEL_ITEMS] = "WheelAmmo";
524
- ConfigStringIndex2[ConfigStringIndex2["WheelPowerups"] = ConfigStringIndex2.WheelAmmo + MAX_WHEEL_ITEMS] = "WheelPowerups";
525
- ConfigStringIndex2[ConfigStringIndex2["CdLoopCount"] = ConfigStringIndex2.WheelPowerups + MAX_WHEEL_ITEMS] = "CdLoopCount";
526
- ConfigStringIndex2[ConfigStringIndex2["GameStyle"] = ConfigStringIndex2.CdLoopCount + 1] = "GameStyle";
527
- ConfigStringIndex2[ConfigStringIndex2["MaxConfigStrings"] = ConfigStringIndex2.GameStyle + 1] = "MaxConfigStrings";
528
- return ConfigStringIndex2;
529
- })(ConfigStringIndex || {});
530
- var MAX_CONFIGSTRINGS = ConfigStringIndex.MaxConfigStrings;
531
- function configStringSize(index) {
532
- if (index >= 5 && index < 59) {
533
- return CS_MAX_STRING_LENGTH * (59 - index);
534
- }
535
- if (index >= ConfigStringIndex.General && index < ConfigStringIndex.WheelWeapons) {
536
- return CS_MAX_STRING_LENGTH * (ConfigStringIndex.MaxConfigStrings - index);
537
- }
538
- return CS_MAX_STRING_LENGTH;
539
- }
540
- var CS_SOUNDS = ConfigStringIndex.Sounds;
541
- var CS_IMAGES = ConfigStringIndex.Images;
542
- var CS_LIGHTS = ConfigStringIndex.Lights;
543
- var CS_ITEMS = ConfigStringIndex.Items;
544
- var CS_PLAYERS = ConfigStringIndex.Players;
545
- var CS_GENERAL = ConfigStringIndex.General;
546
- var replay_exports = {};
547
- __export(replay_exports, {
548
- addReplayFrame: () => addReplayFrame,
549
- createReplaySession: () => createReplaySession,
550
- deserializeReplay: () => deserializeReplay,
551
- serializeReplay: () => serializeReplay
552
- });
553
- function serializeReplay(session) {
554
- return JSON.stringify(session, null, 2);
555
- }
556
- function deserializeReplay(json) {
557
- const session = JSON.parse(json);
558
- if (!session.metadata || !Array.isArray(session.frames)) {
559
- throw new Error("Invalid replay format: missing metadata or frames");
560
- }
561
- return session;
562
- }
563
- function createReplaySession(map, seed) {
564
- return {
565
- metadata: {
566
- map,
567
- date: (/* @__PURE__ */ new Date()).toISOString(),
568
- version: "1.0",
569
- seed
570
- },
571
- frames: []
572
- };
573
- }
574
- function addReplayFrame(session, cmd, serverFrame, startTime) {
575
- session.frames.push({
576
- serverFrame,
577
- cmd,
578
- timestamp: Date.now() - startTime
579
- });
580
- }
581
- var WATERJUMP_CLEAR = 8 | 16 | 32 | 1024;
582
- var ServerCommand = /* @__PURE__ */ ((ServerCommand2) => {
583
- ServerCommand2[ServerCommand2["bad"] = 0] = "bad";
584
- ServerCommand2[ServerCommand2["muzzleflash"] = 1] = "muzzleflash";
585
- ServerCommand2[ServerCommand2["muzzleflash2"] = 2] = "muzzleflash2";
586
- ServerCommand2[ServerCommand2["temp_entity"] = 3] = "temp_entity";
587
- ServerCommand2[ServerCommand2["layout"] = 4] = "layout";
588
- ServerCommand2[ServerCommand2["inventory"] = 5] = "inventory";
589
- ServerCommand2[ServerCommand2["nop"] = 6] = "nop";
590
- ServerCommand2[ServerCommand2["disconnect"] = 7] = "disconnect";
591
- ServerCommand2[ServerCommand2["reconnect"] = 8] = "reconnect";
592
- ServerCommand2[ServerCommand2["sound"] = 9] = "sound";
593
- ServerCommand2[ServerCommand2["print"] = 10] = "print";
594
- ServerCommand2[ServerCommand2["stufftext"] = 11] = "stufftext";
595
- ServerCommand2[ServerCommand2["serverdata"] = 12] = "serverdata";
596
- ServerCommand2[ServerCommand2["configstring"] = 13] = "configstring";
597
- ServerCommand2[ServerCommand2["spawnbaseline"] = 14] = "spawnbaseline";
598
- ServerCommand2[ServerCommand2["centerprint"] = 15] = "centerprint";
599
- ServerCommand2[ServerCommand2["download"] = 16] = "download";
600
- ServerCommand2[ServerCommand2["playerinfo"] = 17] = "playerinfo";
601
- ServerCommand2[ServerCommand2["packetentities"] = 18] = "packetentities";
602
- ServerCommand2[ServerCommand2["deltapacketentities"] = 19] = "deltapacketentities";
603
- ServerCommand2[ServerCommand2["frame"] = 20] = "frame";
604
- ServerCommand2[ServerCommand2["splitclient"] = 21] = "splitclient";
605
- ServerCommand2[ServerCommand2["configblast"] = 22] = "configblast";
606
- ServerCommand2[ServerCommand2["spawnbaselineblast"] = 23] = "spawnbaselineblast";
607
- ServerCommand2[ServerCommand2["level_restart"] = 24] = "level_restart";
608
- ServerCommand2[ServerCommand2["damage"] = 25] = "damage";
609
- ServerCommand2[ServerCommand2["locprint"] = 26] = "locprint";
610
- ServerCommand2[ServerCommand2["fog"] = 27] = "fog";
611
- ServerCommand2[ServerCommand2["waitingforplayers"] = 28] = "waitingforplayers";
612
- ServerCommand2[ServerCommand2["bot_chat"] = 29] = "bot_chat";
613
- ServerCommand2[ServerCommand2["poi"] = 30] = "poi";
614
- ServerCommand2[ServerCommand2["help_path"] = 31] = "help_path";
615
- ServerCommand2[ServerCommand2["muzzleflash3"] = 32] = "muzzleflash3";
616
- ServerCommand2[ServerCommand2["achievement"] = 33] = "achievement";
617
- return ServerCommand2;
618
- })(ServerCommand || {});
619
- var ClientCommand = /* @__PURE__ */ ((ClientCommand2) => {
620
- ClientCommand2[ClientCommand2["bad"] = 0] = "bad";
621
- ClientCommand2[ClientCommand2["nop"] = 1] = "nop";
622
- ClientCommand2[ClientCommand2["move"] = 2] = "move";
623
- ClientCommand2[ClientCommand2["userinfo"] = 3] = "userinfo";
624
- ClientCommand2[ClientCommand2["stringcmd"] = 4] = "stringcmd";
625
- return ClientCommand2;
626
- })(ClientCommand || {});
627
- var TempEntity = /* @__PURE__ */ ((TempEntity2) => {
628
- TempEntity2[TempEntity2["GUNSHOT"] = 0] = "GUNSHOT";
629
- TempEntity2[TempEntity2["BLOOD"] = 1] = "BLOOD";
630
- TempEntity2[TempEntity2["BLASTER"] = 2] = "BLASTER";
631
- TempEntity2[TempEntity2["RAILTRAIL"] = 3] = "RAILTRAIL";
632
- TempEntity2[TempEntity2["SHOTGUN"] = 4] = "SHOTGUN";
633
- TempEntity2[TempEntity2["EXPLOSION1"] = 5] = "EXPLOSION1";
634
- TempEntity2[TempEntity2["EXPLOSION2"] = 6] = "EXPLOSION2";
635
- TempEntity2[TempEntity2["ROCKET_EXPLOSION"] = 7] = "ROCKET_EXPLOSION";
636
- TempEntity2[TempEntity2["GRENADE_EXPLOSION"] = 8] = "GRENADE_EXPLOSION";
637
- TempEntity2[TempEntity2["SPARKS"] = 9] = "SPARKS";
638
- TempEntity2[TempEntity2["SPLASH"] = 10] = "SPLASH";
639
- TempEntity2[TempEntity2["BUBBLETRAIL"] = 11] = "BUBBLETRAIL";
640
- TempEntity2[TempEntity2["SCREEN_SPARKS"] = 12] = "SCREEN_SPARKS";
641
- TempEntity2[TempEntity2["SHIELD_SPARKS"] = 13] = "SHIELD_SPARKS";
642
- TempEntity2[TempEntity2["BULLET_SPARKS"] = 14] = "BULLET_SPARKS";
643
- TempEntity2[TempEntity2["LASER_SPARKS"] = 15] = "LASER_SPARKS";
644
- TempEntity2[TempEntity2["PARASITE_ATTACK"] = 16] = "PARASITE_ATTACK";
645
- TempEntity2[TempEntity2["ROCKET_EXPLOSION_WATER"] = 17] = "ROCKET_EXPLOSION_WATER";
646
- TempEntity2[TempEntity2["GRENADE_EXPLOSION_WATER"] = 18] = "GRENADE_EXPLOSION_WATER";
647
- TempEntity2[TempEntity2["MEDIC_CABLE_ATTACK"] = 19] = "MEDIC_CABLE_ATTACK";
648
- TempEntity2[TempEntity2["BFG_EXPLOSION"] = 20] = "BFG_EXPLOSION";
649
- TempEntity2[TempEntity2["BFG_BIGEXPLOSION"] = 21] = "BFG_BIGEXPLOSION";
650
- TempEntity2[TempEntity2["BOSSTPORT"] = 22] = "BOSSTPORT";
651
- TempEntity2[TempEntity2["BFG_LASER"] = 23] = "BFG_LASER";
652
- TempEntity2[TempEntity2["GRAPPLE_CABLE"] = 24] = "GRAPPLE_CABLE";
653
- TempEntity2[TempEntity2["WELDING_SPARKS"] = 25] = "WELDING_SPARKS";
654
- TempEntity2[TempEntity2["GREENBLOOD"] = 26] = "GREENBLOOD";
655
- TempEntity2[TempEntity2["BLUEHYPERBLASTER"] = 27] = "BLUEHYPERBLASTER";
656
- TempEntity2[TempEntity2["PLASMA_EXPLOSION"] = 28] = "PLASMA_EXPLOSION";
657
- TempEntity2[TempEntity2["TUNNEL_SPARKS"] = 29] = "TUNNEL_SPARKS";
658
- TempEntity2[TempEntity2["BLASTER2"] = 30] = "BLASTER2";
659
- TempEntity2[TempEntity2["RAILTRAIL2"] = 31] = "RAILTRAIL2";
660
- TempEntity2[TempEntity2["FLAME"] = 32] = "FLAME";
661
- TempEntity2[TempEntity2["LIGHTNING"] = 33] = "LIGHTNING";
662
- TempEntity2[TempEntity2["DEBUGTRAIL"] = 34] = "DEBUGTRAIL";
663
- TempEntity2[TempEntity2["PLAIN_EXPLOSION"] = 35] = "PLAIN_EXPLOSION";
664
- TempEntity2[TempEntity2["FLASHLIGHT"] = 36] = "FLASHLIGHT";
665
- TempEntity2[TempEntity2["FORCEWALL"] = 37] = "FORCEWALL";
666
- TempEntity2[TempEntity2["HEATBEAM"] = 38] = "HEATBEAM";
667
- TempEntity2[TempEntity2["MONSTER_HEATBEAM"] = 39] = "MONSTER_HEATBEAM";
668
- TempEntity2[TempEntity2["STEAM"] = 40] = "STEAM";
669
- TempEntity2[TempEntity2["BUBBLETRAIL2"] = 41] = "BUBBLETRAIL2";
670
- TempEntity2[TempEntity2["MOREBLOOD"] = 42] = "MOREBLOOD";
671
- TempEntity2[TempEntity2["HEATBEAM_SPARKS"] = 43] = "HEATBEAM_SPARKS";
672
- TempEntity2[TempEntity2["HEATBEAM_STEAM"] = 44] = "HEATBEAM_STEAM";
673
- TempEntity2[TempEntity2["CHAINFIST_SMOKE"] = 45] = "CHAINFIST_SMOKE";
674
- TempEntity2[TempEntity2["ELECTRIC_SPARKS"] = 46] = "ELECTRIC_SPARKS";
675
- TempEntity2[TempEntity2["TRACKER_EXPLOSION"] = 47] = "TRACKER_EXPLOSION";
676
- TempEntity2[TempEntity2["TELEPORT_EFFECT"] = 48] = "TELEPORT_EFFECT";
677
- TempEntity2[TempEntity2["DBALL_GOAL"] = 49] = "DBALL_GOAL";
678
- TempEntity2[TempEntity2["WIDOWBEAMOUT"] = 50] = "WIDOWBEAMOUT";
679
- TempEntity2[TempEntity2["NUKEBLAST"] = 51] = "NUKEBLAST";
680
- TempEntity2[TempEntity2["WIDOWSPLASH"] = 52] = "WIDOWSPLASH";
681
- TempEntity2[TempEntity2["EXPLOSION1_BIG"] = 53] = "EXPLOSION1_BIG";
682
- TempEntity2[TempEntity2["EXPLOSION1_NP"] = 54] = "EXPLOSION1_NP";
683
- TempEntity2[TempEntity2["FLECHETTE"] = 55] = "FLECHETTE";
684
- TempEntity2[TempEntity2["BLUEHYPERBLASTER_KEX"] = 56] = "BLUEHYPERBLASTER_KEX";
685
- TempEntity2[TempEntity2["BFG_ZAP"] = 57] = "BFG_ZAP";
686
- TempEntity2[TempEntity2["BERSERK_SLAM"] = 58] = "BERSERK_SLAM";
687
- TempEntity2[TempEntity2["GRAPPLE_CABLE_2"] = 59] = "GRAPPLE_CABLE_2";
688
- TempEntity2[TempEntity2["POWER_SPLASH"] = 60] = "POWER_SPLASH";
689
- TempEntity2[TempEntity2["LIGHTNING_BEAM"] = 61] = "LIGHTNING_BEAM";
690
- TempEntity2[TempEntity2["EXPLOSION1_NL"] = 62] = "EXPLOSION1_NL";
691
- TempEntity2[TempEntity2["EXPLOSION2_NL"] = 63] = "EXPLOSION2_NL";
692
- return TempEntity2;
693
- })(TempEntity || {});
694
- var CMD_BACKUP = 64;
695
- var AMMO_MAX = 12;
696
- var NUM_BITS_FOR_AMMO = 9;
697
- var NUM_AMMO_STATS = Math.ceil(AMMO_MAX * NUM_BITS_FOR_AMMO / 16);
698
- var POWERUP_MAX = 23;
699
- var NUM_BITS_FOR_POWERUP = 2;
700
- var NUM_POWERUP_STATS = Math.ceil(POWERUP_MAX * NUM_BITS_FOR_POWERUP / 16);
701
- function writeUserCommand(writer, cmd) {
702
- writer.writeByte(cmd.msec);
703
- writer.writeByte(cmd.buttons);
704
- writer.writeAngle16(cmd.angles.x);
705
- writer.writeAngle16(cmd.angles.y);
706
- writer.writeAngle16(cmd.angles.z);
707
- writer.writeShort(cmd.forwardmove);
708
- writer.writeShort(cmd.sidemove);
709
- writer.writeShort(cmd.upmove);
710
- writer.writeByte(cmd.impulse);
711
- writer.writeByte(0);
712
- }
713
- var crc_table = [
714
- 0,
715
- 145,
716
- 227,
717
- 114,
718
- 7,
719
- 150,
720
- 228,
721
- 117,
722
- 14,
723
- 159,
724
- 237,
725
- 124,
726
- 9,
727
- 152,
728
- 234,
729
- 123,
730
- 28,
731
- 141,
732
- 255,
733
- 110,
734
- 27,
735
- 138,
736
- 248,
737
- 105,
738
- 18,
739
- 131,
740
- 241,
741
- 96,
742
- 21,
743
- 132,
744
- 246,
745
- 103,
746
- 56,
747
- 169,
748
- 219,
749
- 74,
750
- 63,
751
- 174,
752
- 220,
753
- 77,
754
- 54,
755
- 167,
756
- 213,
757
- 68,
758
- 49,
759
- 160,
760
- 210,
761
- 67,
762
- 36,
763
- 181,
764
- 199,
765
- 86,
766
- 35,
767
- 178,
768
- 192,
769
- 81,
770
- 42,
771
- 187,
772
- 201,
773
- 88,
774
- 45,
775
- 188,
776
- 206,
777
- 95,
778
- 112,
779
- 225,
780
- 147,
781
- 2,
782
- 119,
783
- 230,
784
- 148,
785
- 5,
786
- 126,
787
- 239,
788
- 157,
789
- 12,
790
- 121,
791
- 232,
792
- 154,
793
- 11,
794
- 108,
795
- 253,
796
- 143,
797
- 30,
798
- 107,
799
- 250,
800
- 136,
801
- 25,
802
- 98,
803
- 243,
804
- 129,
805
- 16,
806
- 101,
807
- 244,
808
- 134,
809
- 23,
810
- 72,
811
- 217,
812
- 171,
813
- 58,
814
- 79,
815
- 222,
816
- 172,
817
- 61,
818
- 70,
819
- 215,
820
- 165,
821
- 52,
822
- 65,
823
- 208,
824
- 162,
825
- 51,
826
- 84,
827
- 197,
828
- 183,
829
- 38,
830
- 83,
831
- 194,
832
- 176,
833
- 33,
834
- 90,
835
- 203,
836
- 185,
837
- 40,
838
- 93,
839
- 204,
840
- 190,
841
- 47,
842
- 224,
843
- 113,
844
- 3,
845
- 146,
846
- 231,
847
- 118,
848
- 4,
849
- 149,
850
- 238,
851
- 127,
852
- 13,
853
- 156,
854
- 233,
855
- 120,
856
- 10,
857
- 155,
858
- 252,
859
- 109,
860
- 31,
861
- 142,
862
- 251,
863
- 106,
864
- 24,
865
- 137,
866
- 242,
867
- 99,
868
- 17,
869
- 128,
870
- 245,
871
- 100,
872
- 22,
873
- 135,
874
- 216,
875
- 73,
876
- 59,
877
- 170,
878
- 223,
879
- 78,
880
- 60,
881
- 173,
882
- 214,
883
- 71,
884
- 53,
885
- 164,
886
- 209,
887
- 64,
888
- 50,
889
- 163,
890
- 196,
891
- 85,
892
- 39,
893
- 182,
894
- 195,
895
- 82,
896
- 32,
897
- 177,
898
- 202,
899
- 91,
900
- 41,
901
- 184,
902
- 205,
903
- 92,
904
- 46,
905
- 191,
906
- 144,
907
- 1,
908
- 115,
909
- 226,
910
- 151,
911
- 6,
912
- 116,
913
- 229,
914
- 158,
915
- 15,
916
- 125,
917
- 236,
918
- 153,
919
- 8,
920
- 122,
921
- 235,
922
- 140,
923
- 29,
924
- 111,
925
- 254,
926
- 139,
927
- 26,
928
- 104,
929
- 249,
930
- 130,
931
- 19,
932
- 97,
933
- 240,
934
- 133,
935
- 20,
936
- 102,
937
- 247,
938
- 168,
939
- 57,
940
- 75,
941
- 218,
942
- 175,
943
- 62,
944
- 76,
945
- 221,
946
- 166,
947
- 55,
948
- 69,
949
- 212,
950
- 161,
951
- 48,
952
- 66,
953
- 211,
954
- 180,
955
- 37,
956
- 86,
957
- 199,
958
- 179,
959
- 34,
960
- 80,
961
- 193,
962
- 186,
963
- 43,
964
- 89,
965
- 200,
966
- 189,
967
- 44,
968
- 94,
969
- 207
970
- ];
971
- function crc8(data) {
972
- let crc = 0;
973
- for (let i = 0; i < data.length; i++) {
974
- crc = crc_table[(crc ^ data[i]) & 255];
975
- }
976
- return crc;
977
- }
978
- var U_ORIGIN1 = 1 << 0;
979
- var U_ORIGIN2 = 1 << 1;
980
- var U_ANGLE2 = 1 << 2;
981
- var U_ANGLE3 = 1 << 3;
982
- var U_FRAME8 = 1 << 4;
983
- var U_EVENT = 1 << 5;
984
- var U_REMOVE = 1 << 6;
985
- var U_MOREBITS1 = 1 << 7;
986
- var U_NUMBER16 = 1 << 8;
987
- var U_ORIGIN3 = 1 << 9;
988
- var U_ANGLE1 = 1 << 10;
989
- var U_MODEL = 1 << 11;
990
- var U_RENDERFX8 = 1 << 12;
991
- var U_ALPHA = 1 << 13;
992
- var U_EFFECTS8 = 1 << 14;
993
- var U_MOREBITS2 = 1 << 15;
994
- var U_SKIN8 = 1 << 16;
995
- var U_FRAME16 = 1 << 17;
996
- var U_RENDERFX16 = 1 << 18;
997
- var U_EFFECTS16 = 1 << 19;
998
- var U_MODEL2 = 1 << 20;
999
- var U_MODEL3 = 1 << 21;
1000
- var U_MODEL4 = 1 << 22;
1001
- var U_MOREBITS3 = 1 << 23;
1002
- var U_OLDORIGIN = 1 << 24;
1003
- var U_SKIN16 = 1 << 25;
1004
- var U_SOUND = 1 << 26;
1005
- var U_SOLID = 1 << 27;
1006
- var U_SCALE = 1 << 28;
1007
- var U_INSTANCE_BITS = 1 << 29;
1008
- var U_LOOP_VOLUME = 1 << 30;
1009
- var U_MOREBITS4 = 2147483648 | 0;
1010
- var U_LOOP_ATTENUATION_HIGH = 1 << 0;
1011
- var U_OWNER_HIGH = 1 << 1;
1012
- var U_OLD_FRAME_HIGH = 1 << 2;
1013
- var PS_M_TYPE = 1 << 0;
1014
- var PS_M_ORIGIN = 1 << 1;
1015
- var PS_M_VELOCITY = 1 << 2;
1016
- var PS_M_TIME = 1 << 3;
1017
- var PS_M_FLAGS = 1 << 4;
1018
- var PS_M_GRAVITY = 1 << 5;
1019
- var PS_M_DELTA_ANGLES = 1 << 6;
1020
- var PS_VIEWOFFSET = 1 << 7;
1021
- var PS_VIEWANGLES = 1 << 8;
1022
- var PS_KICKANGLES = 1 << 9;
1023
- var PS_BLEND = 1 << 10;
1024
- var PS_FOV = 1 << 11;
1025
- var PS_WEAPONINDEX = 1 << 12;
1026
- var PS_WEAPONFRAME = 1 << 13;
1027
- var PS_RDFLAGS = 1 << 14;
1028
- var PS_WATERTYPE = 1 << 15;
1029
- var BinaryStream = class {
1030
- constructor(buffer) {
1031
- if (buffer instanceof Uint8Array) {
1032
- this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
1033
- } else {
1034
- this.view = new DataView(buffer);
1035
- }
1036
- this.offset = 0;
1037
- this.length = this.view.byteLength;
1038
- }
1039
- getPosition() {
1040
- return this.offset;
1041
- }
1042
- getReadPosition() {
1043
- return this.offset;
1044
- }
1045
- getLength() {
1046
- return this.length;
1047
- }
1048
- getRemaining() {
1049
- return this.length - this.offset;
1050
- }
1051
- seek(position) {
1052
- if (position < 0 || position > this.length) {
1053
- throw new Error(`Seek out of bounds: ${position} (length: ${this.length})`);
1054
- }
1055
- this.offset = position;
1056
- }
1057
- setReadPosition(position) {
1058
- this.seek(position);
1059
- }
1060
- hasMore() {
1061
- return this.offset < this.length;
1062
- }
1063
- hasBytes(count) {
1064
- return this.offset + count <= this.length;
1065
- }
1066
- readChar() {
1067
- const value = this.view.getInt8(this.offset);
1068
- this.offset += 1;
1069
- return value;
1070
- }
1071
- readByte() {
1072
- const value = this.view.getUint8(this.offset);
1073
- this.offset += 1;
1074
- return value;
1075
- }
1076
- readShort() {
1077
- const value = this.view.getInt16(this.offset, true);
1078
- this.offset += 2;
1079
- return value;
1080
- }
1081
- readUShort() {
1082
- const value = this.view.getUint16(this.offset, true);
1083
- this.offset += 2;
1084
- return value;
1085
- }
1086
- readLong() {
1087
- const value = this.view.getInt32(this.offset, true);
1088
- this.offset += 4;
1089
- return value;
1090
- }
1091
- readULong() {
1092
- const value = this.view.getUint32(this.offset, true);
1093
- this.offset += 4;
1094
- return value;
1095
- }
1096
- readFloat() {
1097
- const value = this.view.getFloat32(this.offset, true);
1098
- this.offset += 4;
1099
- return value;
1100
- }
1101
- readString() {
1102
- let str = "";
1103
- while (this.offset < this.length) {
1104
- const charCode = this.readChar();
1105
- if (charCode === -1 || charCode === 0) {
1106
- break;
1107
- }
1108
- str += String.fromCharCode(charCode);
1109
- }
1110
- return str;
1111
- }
1112
- readStringLine() {
1113
- let str = "";
1114
- while (this.offset < this.length) {
1115
- const charCode = this.readChar();
1116
- if (charCode === -1 || charCode === 0 || charCode === 10) {
1117
- break;
1118
- }
1119
- str += String.fromCharCode(charCode);
1120
- }
1121
- return str;
1122
- }
1123
- readCoord() {
1124
- return this.readShort() * (1 / 8);
1125
- }
1126
- readAngle() {
1127
- return this.readChar() * (360 / 256);
1128
- }
1129
- readAngle16() {
1130
- return this.readShort() * 360 / 65536;
1131
- }
1132
- readData(length) {
1133
- if (this.offset + length > this.length) {
1134
- throw new Error(`Read out of bounds: ${this.offset + length} (length: ${this.length})`);
1135
- }
1136
- const data = new Uint8Array(this.view.buffer, this.view.byteOffset + this.offset, length);
1137
- this.offset += length;
1138
- return new Uint8Array(data);
1139
- }
1140
- readPos(out) {
1141
- out.x = this.readCoord();
1142
- out.y = this.readCoord();
1143
- out.z = this.readCoord();
1144
- }
1145
- readDir(out) {
1146
- const b = this.readByte();
1147
- if (b >= 162) {
1148
- out.x = 0;
1149
- out.y = 0;
1150
- out.z = 0;
1151
- return;
1152
- }
1153
- const norm = ANORMS[b];
1154
- out.x = norm[0];
1155
- out.y = norm[1];
1156
- out.z = norm[2];
1157
- }
1158
- };
1159
- var BinaryWriter = class {
1160
- constructor(sizeOrBuffer = 1400) {
1161
- if (typeof sizeOrBuffer === "number") {
1162
- this.buffer = new Uint8Array(sizeOrBuffer);
1163
- this.fixed = false;
1164
- } else {
1165
- this.buffer = sizeOrBuffer;
1166
- this.fixed = true;
1167
- }
1168
- this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
1169
- this.offset = 0;
1170
- }
1171
- ensureSpace(bytes) {
1172
- if (this.offset + bytes > this.buffer.byteLength) {
1173
- if (this.fixed) {
1174
- throw new Error(`Buffer overflow: capacity ${this.buffer.byteLength}, needed ${this.offset + bytes}`);
1175
- }
1176
- const newSize = Math.max(this.buffer.byteLength * 2, this.offset + bytes);
1177
- const newBuffer = new Uint8Array(newSize);
1178
- newBuffer.set(this.buffer);
1179
- this.buffer = newBuffer;
1180
- this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
1181
- }
1182
- }
1183
- writeByte(value) {
1184
- this.ensureSpace(1);
1185
- this.view.setUint8(this.offset, value);
1186
- this.offset += 1;
1187
- }
1188
- writeBytes(data) {
1189
- this.ensureSpace(data.byteLength);
1190
- this.buffer.set(data, this.offset);
1191
- this.offset += data.byteLength;
1192
- }
1193
- writeChar(value) {
1194
- this.ensureSpace(1);
1195
- this.view.setInt8(this.offset, value);
1196
- this.offset += 1;
1197
- }
1198
- writeShort(value) {
1199
- this.ensureSpace(2);
1200
- this.view.setInt16(this.offset, value, true);
1201
- this.offset += 2;
1202
- }
1203
- writeLong(value) {
1204
- this.ensureSpace(4);
1205
- this.view.setInt32(this.offset, value, true);
1206
- this.offset += 4;
1207
- }
1208
- writeFloat(value) {
1209
- this.ensureSpace(4);
1210
- this.view.setFloat32(this.offset, value, true);
1211
- this.offset += 4;
1212
- }
1213
- writeString(value) {
1214
- const len = value.length;
1215
- this.ensureSpace(len + 1);
1216
- for (let i = 0; i < len; i++) {
1217
- this.view.setUint8(this.offset + i, value.charCodeAt(i));
1218
- }
1219
- this.view.setUint8(this.offset + len, 0);
1220
- this.offset += len + 1;
1221
- }
1222
- writeCoord(value) {
1223
- this.writeShort(Math.trunc(value * 8));
1224
- }
1225
- writeAngle(value) {
1226
- this.writeByte(Math.trunc(value * 256 / 360) & 255);
1227
- }
1228
- writeAngle16(value) {
1229
- this.writeShort(Math.trunc(value * 65536 / 360) & 65535);
1230
- }
1231
- writePos(pos) {
1232
- this.writeCoord(pos.x);
1233
- this.writeCoord(pos.y);
1234
- this.writeCoord(pos.z);
1235
- }
1236
- writeDir(dir) {
1237
- let maxDot = -1;
1238
- let bestIndex = 0;
1239
- if (dir.x === 0 && dir.y === 0 && dir.z === 0) {
1240
- this.writeByte(0);
1241
- return;
1242
- }
1243
- for (let i = 0; i < ANORMS.length; i++) {
1244
- const norm = ANORMS[i];
1245
- const dot = dir.x * norm[0] + dir.y * norm[1] + dir.z * norm[2];
1246
- if (dot > maxDot) {
1247
- maxDot = dot;
1248
- bestIndex = i;
1249
- }
1250
- }
1251
- this.writeByte(bestIndex);
1252
- }
1253
- getData() {
1254
- return this.buffer.slice(0, this.offset);
1255
- }
1256
- getBuffer() {
1257
- return this.buffer;
1258
- }
1259
- getOffset() {
1260
- return this.offset;
1261
- }
1262
- reset() {
1263
- this.offset = 0;
1264
- }
1265
- };
1266
- var NetworkMessageBuilder = class {
1267
- constructor(initialSize = 1024) {
1268
- this.buffer = new Uint8Array(initialSize);
1269
- this.view = new DataView(this.buffer.buffer);
1270
- this.offset = 0;
1271
- }
1272
- ensureCapacity(needed) {
1273
- if (this.offset + needed > this.buffer.length) {
1274
- const newSize = Math.max(this.buffer.length * 2, this.offset + needed);
1275
- const newBuffer = new Uint8Array(newSize);
1276
- newBuffer.set(this.buffer);
1277
- this.buffer = newBuffer;
1278
- this.view = new DataView(this.buffer.buffer);
1279
- }
1280
- }
1281
- getData() {
1282
- return this.buffer.slice(0, this.offset);
1283
- }
1284
- writeByte(value) {
1285
- this.ensureCapacity(1);
1286
- this.view.setUint8(this.offset, value);
1287
- this.offset += 1;
1288
- }
1289
- writeChar(value) {
1290
- this.ensureCapacity(1);
1291
- this.view.setInt8(this.offset, value);
1292
- this.offset += 1;
1293
- }
1294
- writeShort(value) {
1295
- this.ensureCapacity(2);
1296
- this.view.setInt16(this.offset, value, true);
1297
- this.offset += 2;
1298
- }
1299
- writeUShort(value) {
1300
- this.ensureCapacity(2);
1301
- this.view.setUint16(this.offset, value, true);
1302
- this.offset += 2;
1303
- }
1304
- writeLong(value) {
1305
- this.ensureCapacity(4);
1306
- this.view.setInt32(this.offset, value, true);
1307
- this.offset += 4;
1308
- }
1309
- writeFloat(value) {
1310
- this.ensureCapacity(4);
1311
- this.view.setFloat32(this.offset, value, true);
1312
- this.offset += 4;
1313
- }
1314
- writeString(value) {
1315
- const len = value.length + 1;
1316
- this.ensureCapacity(len);
1317
- for (let i = 0; i < value.length; i++) {
1318
- this.view.setUint8(this.offset + i, value.charCodeAt(i));
1319
- }
1320
- this.view.setUint8(this.offset + value.length, 0);
1321
- this.offset += len;
1322
- }
1323
- writeData(data) {
1324
- this.ensureCapacity(data.length);
1325
- this.buffer.set(data, this.offset);
1326
- this.offset += data.length;
1327
- }
1328
- writeCoord(value) {
1329
- this.writeShort(Math.round(value * 8));
1330
- }
1331
- writeAngle(value) {
1332
- this.writeByte(Math.round(value * 256 / 360) & 255);
1333
- }
1334
- writeAngle16(value) {
1335
- this.writeShort(Math.round(value * 65536 / 360));
1336
- }
1337
- writeDir(x, y, z) {
1338
- let best = 0;
1339
- let bestDot = -999999;
1340
- const len = Math.sqrt(x * x + y * y + z * z);
1341
- if (len > 0) {
1342
- x /= len;
1343
- y /= len;
1344
- z /= len;
1345
- for (let i = 0; i < 162; i++) {
1346
- const dot = x * ANORMS[i][0] + y * ANORMS[i][1] + z * ANORMS[i][2];
1347
- if (dot > bestDot) {
1348
- bestDot = dot;
1349
- best = i;
1350
- }
1351
- }
1352
- }
1353
- this.writeByte(best);
1354
- }
1355
- };
1356
- var _NetChan = class _NetChan2 {
1357
- constructor() {
1358
- this.qport = 0;
1359
- this.incomingSequence = 0;
1360
- this.outgoingSequence = 0;
1361
- this.incomingAcknowledged = 0;
1362
- this.incomingReliableAcknowledged = false;
1363
- this.incomingReliableSequence = 0;
1364
- this.outgoingReliableSequence = 0;
1365
- this.reliableLength = 0;
1366
- this.fragmentSendOffset = 0;
1367
- this.fragmentBuffer = null;
1368
- this.fragmentLength = 0;
1369
- this.fragmentReceived = 0;
1370
- this.lastReceived = 0;
1371
- this.lastSent = 0;
1372
- this.remoteAddress = null;
1373
- this.reliableMessage = new BinaryWriter(_NetChan2.MAX_RELIABLE_BUFFER);
1374
- const now = Date.now();
1375
- this.lastReceived = now;
1376
- this.lastSent = now;
1377
- this.qport = Math.floor(Math.random() * 65536);
1378
- }
1379
- /**
1380
- * Setup the netchan with specific settings
1381
- */
1382
- setup(qport, address = null) {
1383
- this.qport = qport;
1384
- this.remoteAddress = address;
1385
- this.reset();
1386
- }
1387
- /**
1388
- * Reset the netchan state
1389
- */
1390
- reset() {
1391
- this.incomingSequence = 0;
1392
- this.outgoingSequence = 0;
1393
- this.incomingAcknowledged = 0;
1394
- this.incomingReliableAcknowledged = false;
1395
- this.incomingReliableSequence = 0;
1396
- this.outgoingReliableSequence = 0;
1397
- this.reliableLength = 0;
1398
- this.reliableMessage.reset();
1399
- this.fragmentSendOffset = 0;
1400
- this.fragmentBuffer = null;
1401
- this.fragmentLength = 0;
1402
- this.fragmentReceived = 0;
1403
- this.lastReceived = Date.now();
1404
- this.lastSent = Date.now();
1405
- }
1406
- /**
1407
- * Transmits a packet containing reliable and unreliable data
1408
- */
1409
- transmit(unreliableData) {
1410
- this.outgoingSequence++;
1411
- this.lastSent = Date.now();
1412
- let sendReliableLength = 0;
1413
- let isFragment = false;
1414
- let fragmentStart = 0;
1415
- if (this.reliableLength > 0) {
1416
- if (this.reliableLength > _NetChan2.FRAGMENT_SIZE) {
1417
- isFragment = true;
1418
- if (this.fragmentSendOffset >= this.reliableLength) {
1419
- this.fragmentSendOffset = 0;
1420
- }
1421
- const remaining = this.reliableLength - this.fragmentSendOffset;
1422
- sendReliableLength = remaining;
1423
- if (sendReliableLength > _NetChan2.FRAGMENT_SIZE) {
1424
- sendReliableLength = _NetChan2.FRAGMENT_SIZE;
1425
- }
1426
- fragmentStart = this.fragmentSendOffset;
1427
- this.fragmentSendOffset += sendReliableLength;
1428
- } else {
1429
- sendReliableLength = this.reliableLength;
1430
- }
1431
- }
1432
- const headerSize = _NetChan2.PACKET_HEADER;
1433
- const reliableHeaderSize = sendReliableLength > 0 ? 2 + (isFragment ? 8 : 0) : 0;
1434
- let unreliableSize = unreliableData ? unreliableData.length : 0;
1435
- if (headerSize + reliableHeaderSize + sendReliableLength + unreliableSize > _NetChan2.MAX_MSGLEN) {
1436
- unreliableSize = _NetChan2.MAX_MSGLEN - headerSize - reliableHeaderSize - sendReliableLength;
1437
- if (unreliableSize < 0) unreliableSize = 0;
1438
- }
1439
- const buffer = new ArrayBuffer(headerSize + reliableHeaderSize + sendReliableLength + unreliableSize);
1440
- const view = new DataView(buffer);
1441
- const result = new Uint8Array(buffer);
1442
- let sequence = this.outgoingSequence;
1443
- if (sendReliableLength > 0) {
1444
- sequence |= 2147483648;
1445
- if ((this.outgoingReliableSequence & 1) !== 0) {
1446
- sequence |= 1073741824;
1447
- }
1448
- }
1449
- view.setUint32(0, sequence, true);
1450
- let ack = this.incomingSequence;
1451
- if ((this.incomingReliableSequence & 1) !== 0) {
1452
- ack |= 2147483648;
1453
- }
1454
- view.setUint32(4, ack, true);
1455
- view.setUint16(8, this.qport, true);
1456
- let offset = headerSize;
1457
- if (sendReliableLength > 0) {
1458
- let lengthField = sendReliableLength;
1459
- if (isFragment) {
1460
- lengthField |= 32768;
1461
- }
1462
- view.setUint16(offset, lengthField, true);
1463
- offset += 2;
1464
- if (isFragment) {
1465
- view.setUint32(offset, fragmentStart, true);
1466
- offset += 4;
1467
- view.setUint32(offset, this.reliableLength, true);
1468
- offset += 4;
1469
- }
1470
- const reliableBuffer = this.reliableMessage.getBuffer();
1471
- const reliableBytes = reliableBuffer.subarray(fragmentStart, fragmentStart + sendReliableLength);
1472
- result.set(reliableBytes, offset);
1473
- offset += sendReliableLength;
1474
- }
1475
- if (unreliableData && unreliableSize > 0) {
1476
- const chunk = unreliableData.slice(0, unreliableSize);
1477
- result.set(chunk, offset);
1478
- }
1479
- return result;
1480
- }
1481
- /**
1482
- * Processes a received packet
1483
- * Returns the payload data (reliable + unreliable) to be processed, or null if discarded
1484
- */
1485
- process(packet) {
1486
- if (packet.length < _NetChan2.PACKET_HEADER) {
1487
- return null;
1488
- }
1489
- this.lastReceived = Date.now();
1490
- const view = new DataView(packet.buffer, packet.byteOffset, packet.byteLength);
1491
- const sequence = view.getUint32(0, true);
1492
- const ack = view.getUint32(4, true);
1493
- const qport = view.getUint16(8, true);
1494
- if (this.qport !== qport) {
1495
- return null;
1496
- }
1497
- const seqNumberClean = sequence & ~(2147483648 | 1073741824);
1498
- if ((seqNumberClean - this.incomingSequence | 0) <= 0) {
1499
- return null;
1500
- }
1501
- this.incomingSequence = seqNumberClean;
1502
- const ackNumber = ack & ~2147483648;
1503
- const ackReliable = (ack & 2147483648) !== 0;
1504
- if (ackNumber > this.incomingAcknowledged) {
1505
- this.incomingAcknowledged = ackNumber;
1506
- }
1507
- if (this.reliableLength > 0) {
1508
- const receivedAckBit = ackReliable ? 1 : 0;
1509
- const currentReliableBit = this.outgoingReliableSequence & 1;
1510
- if (receivedAckBit !== currentReliableBit) {
1511
- this.reliableLength = 0;
1512
- this.reliableMessage.reset();
1513
- this.outgoingReliableSequence ^= 1;
1514
- this.fragmentSendOffset = 0;
1515
- }
1516
- }
1517
- const hasReliableData = (sequence & 2147483648) !== 0;
1518
- const reliableSeqBit = (sequence & 1073741824) !== 0 ? 1 : 0;
1519
- let payloadOffset = _NetChan2.PACKET_HEADER;
1520
- let reliableData = null;
1521
- if (hasReliableData) {
1522
- if (payloadOffset + 2 > packet.byteLength) return null;
1523
- let reliableLen = view.getUint16(payloadOffset, true);
1524
- payloadOffset += 2;
1525
- const isFragment = (reliableLen & 32768) !== 0;
1526
- reliableLen &= 32767;
1527
- const expectedBit = this.incomingReliableSequence & 1;
1528
- if (reliableSeqBit === expectedBit) {
1529
- if (isFragment) {
1530
- if (payloadOffset + 8 > packet.byteLength) return null;
1531
- const fragStart = view.getUint32(payloadOffset, true);
1532
- payloadOffset += 4;
1533
- const fragTotal = view.getUint32(payloadOffset, true);
1534
- payloadOffset += 4;
1535
- if (fragTotal > _NetChan2.MAX_RELIABLE_BUFFER) {
1536
- console.warn(`NetChan: received invalid fragment total ${fragTotal} > ${_NetChan2.MAX_RELIABLE_BUFFER}`);
1537
- return null;
1538
- }
1539
- if (!this.fragmentBuffer || this.fragmentBuffer.length !== fragTotal) {
1540
- this.fragmentBuffer = new Uint8Array(fragTotal);
1541
- this.fragmentLength = fragTotal;
1542
- this.fragmentReceived = 0;
1543
- }
1544
- if (payloadOffset + reliableLen > packet.byteLength) return null;
1545
- const data = packet.subarray(payloadOffset, payloadOffset + reliableLen);
1546
- if (fragStart === this.fragmentReceived && fragStart + reliableLen <= fragTotal) {
1547
- this.fragmentBuffer.set(data, fragStart);
1548
- this.fragmentReceived += reliableLen;
1549
- if (this.fragmentReceived >= fragTotal) {
1550
- reliableData = this.fragmentBuffer;
1551
- this.incomingReliableSequence++;
1552
- this.fragmentBuffer = null;
1553
- this.fragmentLength = 0;
1554
- this.fragmentReceived = 0;
1555
- }
1556
- }
1557
- } else {
1558
- this.incomingReliableSequence++;
1559
- if (payloadOffset + reliableLen > packet.byteLength) return null;
1560
- reliableData = packet.slice(payloadOffset, payloadOffset + reliableLen);
1561
- }
1562
- }
1563
- payloadOffset += reliableLen;
1564
- }
1565
- const unreliableData = packet.slice(payloadOffset);
1566
- if (reliableData && reliableData.length > 0) {
1567
- const totalLen = reliableData.length + unreliableData.length;
1568
- const result = new Uint8Array(totalLen);
1569
- result.set(reliableData, 0);
1570
- result.set(unreliableData, reliableData.length);
1571
- return result;
1572
- }
1573
- if (unreliableData) {
1574
- return unreliableData;
1575
- }
1576
- return new Uint8Array(0);
1577
- }
1578
- /**
1579
- * Checks if reliable message buffer is empty and ready for new data
1580
- */
1581
- canSendReliable() {
1582
- return this.reliableLength === 0;
1583
- }
1584
- /**
1585
- * Writes a byte to the reliable message buffer
1586
- */
1587
- writeReliableByte(value) {
1588
- if (this.reliableLength + 1 > _NetChan2.MAX_RELIABLE_BUFFER) {
1589
- throw new Error("NetChan reliable buffer overflow");
1590
- }
1591
- this.reliableMessage.writeByte(value);
1592
- this.reliableLength++;
1593
- }
1594
- /**
1595
- * Writes a short to the reliable message buffer
1596
- */
1597
- writeReliableShort(value) {
1598
- if (this.reliableLength + 2 > _NetChan2.MAX_RELIABLE_BUFFER) {
1599
- throw new Error("NetChan reliable buffer overflow");
1600
- }
1601
- this.reliableMessage.writeShort(value);
1602
- this.reliableLength += 2;
1603
- }
1604
- /**
1605
- * Writes a long to the reliable message buffer
1606
- */
1607
- writeReliableLong(value) {
1608
- if (this.reliableLength + 4 > _NetChan2.MAX_RELIABLE_BUFFER) {
1609
- throw new Error("NetChan reliable buffer overflow");
1610
- }
1611
- this.reliableMessage.writeLong(value);
1612
- this.reliableLength += 4;
1613
- }
1614
- /**
1615
- * Writes a string to the reliable message buffer
1616
- */
1617
- writeReliableString(value) {
1618
- const len = value.length + 1;
1619
- if (this.reliableLength + len > _NetChan2.MAX_RELIABLE_BUFFER) {
1620
- throw new Error("NetChan reliable buffer overflow");
1621
- }
1622
- this.reliableMessage.writeString(value);
1623
- this.reliableLength += len;
1624
- }
1625
- /**
1626
- * Returns the current reliable data buffer
1627
- */
1628
- getReliableData() {
1629
- if (this.reliableLength === 0) {
1630
- return new Uint8Array(0);
1631
- }
1632
- const buffer = this.reliableMessage.getBuffer();
1633
- return buffer.subarray(0, this.reliableLength);
1634
- }
1635
- /**
1636
- * Checks if we need to send a keepalive packet
1637
- */
1638
- needsKeepalive(currentTime) {
1639
- return currentTime - this.lastSent > 1e3;
1640
- }
1641
- /**
1642
- * Checks if the connection has timed out
1643
- */
1644
- isTimedOut(currentTime, timeoutMs = 3e4) {
1645
- return currentTime - this.lastReceived > timeoutMs;
1646
- }
1647
- };
1648
- _NetChan.MAX_MSGLEN = 1400;
1649
- _NetChan.FRAGMENT_SIZE = 1024;
1650
- _NetChan.PACKET_HEADER = 10;
1651
- _NetChan.HEADER_OVERHEAD = _NetChan.PACKET_HEADER + 2;
1652
- _NetChan.MAX_RELIABLE_BUFFER = 262144;
1653
- var NetChan = _NetChan;
1654
- var AmmoType = /* @__PURE__ */ ((AmmoType2) => {
1655
- AmmoType2[AmmoType2["Bullets"] = 0] = "Bullets";
1656
- AmmoType2[AmmoType2["Shells"] = 1] = "Shells";
1657
- AmmoType2[AmmoType2["Rockets"] = 2] = "Rockets";
1658
- AmmoType2[AmmoType2["Grenades"] = 3] = "Grenades";
1659
- AmmoType2[AmmoType2["Cells"] = 4] = "Cells";
1660
- AmmoType2[AmmoType2["Slugs"] = 5] = "Slugs";
1661
- AmmoType2[AmmoType2["MagSlugs"] = 6] = "MagSlugs";
1662
- AmmoType2[AmmoType2["Trap"] = 7] = "Trap";
1663
- AmmoType2[AmmoType2["Flechettes"] = 8] = "Flechettes";
1664
- AmmoType2[AmmoType2["Tesla"] = 9] = "Tesla";
1665
- AmmoType2[AmmoType2["Disruptor"] = 10] = "Disruptor";
1666
- AmmoType2[AmmoType2["Prox"] = 11] = "Prox";
1667
- AmmoType2[AmmoType2["Nuke"] = 12] = "Nuke";
1668
- AmmoType2[AmmoType2["Rounds"] = 13] = "Rounds";
1669
- return AmmoType2;
1670
- })(AmmoType || {});
1671
- var AMMO_TYPE_COUNT = Object.keys(AmmoType).length / 2;
1672
- var MAX_SOUND_CHANNELS = 32;
1673
- var SoundChannel = /* @__PURE__ */ ((SoundChannel2) => {
1674
- SoundChannel2[SoundChannel2["Auto"] = 0] = "Auto";
1675
- SoundChannel2[SoundChannel2["Weapon"] = 1] = "Weapon";
1676
- SoundChannel2[SoundChannel2["Voice"] = 2] = "Voice";
1677
- SoundChannel2[SoundChannel2["Item"] = 3] = "Item";
1678
- SoundChannel2[SoundChannel2["Body"] = 4] = "Body";
1679
- SoundChannel2[SoundChannel2["Aux"] = 5] = "Aux";
1680
- SoundChannel2[SoundChannel2["Footstep"] = 6] = "Footstep";
1681
- SoundChannel2[SoundChannel2["Aux3"] = 7] = "Aux3";
1682
- SoundChannel2[SoundChannel2["NoPhsAdd"] = 8] = "NoPhsAdd";
1683
- SoundChannel2[SoundChannel2["Reliable"] = 16] = "Reliable";
1684
- SoundChannel2[SoundChannel2["ForcePos"] = 32] = "ForcePos";
1685
- return SoundChannel2;
1686
- })(SoundChannel || {});
1687
- var ATTN_LOOP_NONE = -1;
1688
- var ATTN_NONE = 0;
1689
- var ATTN_NORM = 1;
1690
- var ATTN_IDLE = 2;
1691
- var ATTN_STATIC = 3;
1692
- var SOUND_FULLVOLUME = 80;
1693
- var SOUND_LOOP_ATTENUATE = 3e-3;
1694
- function attenuationToDistanceMultiplier(attenuation) {
1695
- return attenuation * 1e-3;
1696
- }
1697
- function calculateMaxAudibleDistance(attenuation) {
1698
- const distMult = attenuationToDistanceMultiplier(attenuation);
1699
- return distMult <= 0 ? Number.POSITIVE_INFINITY : SOUND_FULLVOLUME + 1 / distMult;
1700
- }
1701
-
1702
- // src/cvars.ts
1703
188
  var Cvar = class {
1704
189
  constructor({
1705
190
  name,
@@ -2048,8 +533,6 @@ function createEngineRuntime(engine, game, client, audioOptions, options) {
2048
533
  const runtime = new EngineRuntime(engine, host);
2049
534
  return { runtime, audio };
2050
535
  }
2051
-
2052
- // src/configstrings.ts
2053
536
  function assertWithinBounds(index) {
2054
537
  if (index < 0 || index >= ConfigStringIndex.MaxConfigStrings) {
2055
538
  throw new RangeError(`Configstring index ${index} is out of range (0-${ConfigStringIndex.MaxConfigStrings - 1})`);
@@ -2320,8 +803,7 @@ var StreamingPakArchive = class {
2320
803
  const normalized = normalizePath2(rawName);
2321
804
  const fileOffset = dirView.getInt32(offset + 56, true);
2322
805
  const fileLength = dirView.getInt32(offset + 60, true);
2323
- if (fileOffset < 0 || fileLength < 0 || fileOffset + fileLength > this.source.size) {
2324
- }
806
+ if (fileOffset < 0 || fileLength < 0 || fileOffset + fileLength > this.source.size) ;
2325
807
  if (normalized) {
2326
808
  entries.set(normalized, { name: normalized, offset: fileOffset, length: fileLength });
2327
809
  }
@@ -2738,11 +1220,10 @@ var VirtualFileSystem = class {
2738
1220
  }).sort((a, b) => a.path.localeCompare(b.path));
2739
1221
  for (const file of allFiles) {
2740
1222
  const parts = file.path.split("/");
2741
- const fileName = parts.pop();
1223
+ parts.pop();
2742
1224
  let currentPath = "";
2743
1225
  let currentNode = root;
2744
1226
  for (const part of parts) {
2745
- const parentPath = currentPath;
2746
1227
  currentPath = currentPath ? `${currentPath}/${part}` : part;
2747
1228
  let nextNode = nodeMap.get(currentPath);
2748
1229
  if (!nextNode) {
@@ -3690,8 +2171,6 @@ function createFaceLightmap(face, lightMaps, info) {
3690
2171
  }
3691
2172
  return lightMaps.subarray(face.lightOffset, face.lightOffset + length);
3692
2173
  }
3693
-
3694
- // src/assets/md2.ts
3695
2174
  var MD2_MAGIC = 844121161;
3696
2175
  var MD2_VERSION = 8;
3697
2176
  var HEADER_SIZE5 = 68;
@@ -4427,7 +2906,6 @@ function parseTga(buffer) {
4427
2906
  const pixelCount = width * height;
4428
2907
  const pixels = new Uint8Array(pixelCount * 4);
4429
2908
  const originTopLeft = (imageDescriptor & 32) !== 0;
4430
- let currentPixel = 0;
4431
2909
  const rawData = new Uint8Array(buffer);
4432
2910
  const readPixel = (outIndex) => {
4433
2911
  if (isGrayscale) {
@@ -4603,7 +3081,6 @@ function parseWav(buffer) {
4603
3081
  let offset = 12;
4604
3082
  let fmtOffset = -1;
4605
3083
  let dataOffset = -1;
4606
- let fmtSize = 0;
4607
3084
  let dataSize = 0;
4608
3085
  while (offset + 8 <= buffer.byteLength) {
4609
3086
  const chunkId = readString2(view, offset, 4);
@@ -4611,7 +3088,6 @@ function parseWav(buffer) {
4611
3088
  const chunkDataOffset = offset + 8;
4612
3089
  if (chunkId === "fmt ") {
4613
3090
  fmtOffset = chunkDataOffset;
4614
- fmtSize = chunkSize;
4615
3091
  } else if (chunkId === "data") {
4616
3092
  dataOffset = chunkDataOffset;
4617
3093
  dataSize = chunkSize;
@@ -4655,9 +3131,6 @@ function parseWav(buffer) {
4655
3131
  }
4656
3132
  return { sampleRate, channels, bitsPerSample, samples };
4657
3133
  }
4658
-
4659
- // src/assets/ogg.ts
4660
- import { OggVorbisDecoder } from "@wasm-audio-decoders/ogg-vorbis";
4661
3134
  var OggDecodeError = class extends Error {
4662
3135
  constructor(message) {
4663
3136
  super(message);
@@ -5561,14 +4034,11 @@ var AudioSystem = class {
5561
4034
  const startTimeSec = ctx.currentTime + (request.timeOffsetMs ?? 0) / 1e3;
5562
4035
  const endTimeMs = (request.looping ? Number.POSITIVE_INFINITY : buffer.duration * 1e3) + startTimeSec * 1e3;
5563
4036
  source.connect(panner);
5564
- let finalNode = panner;
5565
4037
  if (occlusionFilter) {
5566
4038
  panner.connect(occlusionFilter);
5567
4039
  occlusionFilter.connect(gain);
5568
- finalNode = gain;
5569
4040
  } else {
5570
4041
  panner.connect(gain);
5571
- finalNode = gain;
5572
4042
  }
5573
4043
  gain.connect(this.graph.master);
5574
4044
  if (this.reverb) {
@@ -5734,8 +4204,6 @@ var AudioSystem = class {
5734
4204
  };
5735
4205
  var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
5736
4206
  var clamp01 = (value) => clamp(value, 0, 1);
5737
-
5738
- // src/audio/occlusion.ts
5739
4207
  var AudioOcclusion = class {
5740
4208
  constructor(trace) {
5741
4209
  this.trace = trace;
@@ -5818,8 +4286,7 @@ var MusicSystem = class {
5818
4286
  await element.play();
5819
4287
  } catch (e) {
5820
4288
  console.warn(`MusicSystem: Failed to play ${track}`, e);
5821
- if (this.fadingElement) {
5822
- }
4289
+ if (this.fadingElement) ;
5823
4290
  }
5824
4291
  this.currentElement = element;
5825
4292
  this.track = track;
@@ -6231,8 +4698,6 @@ var Framebuffer = class {
6231
4698
  this.gl.deleteFramebuffer(this.framebuffer);
6232
4699
  }
6233
4700
  };
6234
-
6235
- // src/render/bsp.ts
6236
4701
  var FLOAT_BYTES = 4;
6237
4702
  var STRIDE = 7 * FLOAT_BYTES;
6238
4703
  var BSP_VERTEX_LAYOUT = [
@@ -7486,7 +5951,7 @@ void main() {
7486
5951
 
7487
5952
  o_color = finalColor;
7488
5953
  }`;
7489
- function normalizeVec32(v) {
5954
+ function normalizeVec3(v) {
7490
5955
  const lengthSq = v.x * v.x + v.y * v.y + v.z * v.z;
7491
5956
  if (lengthSq <= 0) {
7492
5957
  return { x: 0, y: 0, z: 1 };
@@ -7567,7 +6032,7 @@ function buildMd2VertexData(model, geometry, blend) {
7567
6032
  throw new Error("MD2 vertex index out of range for frame");
7568
6033
  }
7569
6034
  const position = lerpVec3(vA.position, vB.position, lerp3);
7570
- const normal = normalizeVec32(lerpVec3(vA.normal, vB.normal, lerp3));
6035
+ const normal = normalizeVec3(lerpVec3(vA.normal, vB.normal, lerp3));
7571
6036
  const base = index * 8;
7572
6037
  data[base] = position.x;
7573
6038
  data[base + 1] = position.y;
@@ -7684,8 +6149,7 @@ var Md2Pipeline = class {
7684
6149
  else if (renderMode.mode === "solid-faceted") modeInt = 2;
7685
6150
  if (renderMode.color) {
7686
6151
  color = [...renderMode.color];
7687
- } else if (renderMode.generateRandomColor) {
7688
- }
6152
+ } else if (renderMode.generateRandomColor) ;
7689
6153
  }
7690
6154
  this.gl.uniform1i(this.uniformRenderMode, modeInt);
7691
6155
  this.gl.uniform4f(this.uniformSolidColor, color[0], color[1], color[2], color[3]);
@@ -7722,9 +6186,6 @@ var Md2Pipeline = class {
7722
6186
  this.program.dispose();
7723
6187
  }
7724
6188
  };
7725
-
7726
- // src/render/camera.ts
7727
- import { mat4, vec3 } from "gl-matrix";
7728
6189
  var Camera = class {
7729
6190
  constructor() {
7730
6191
  this._position = vec3.create();
@@ -7958,8 +6419,6 @@ var Camera = class {
7958
6419
  this._dirty = false;
7959
6420
  }
7960
6421
  };
7961
-
7962
- // src/render/md3Pipeline.ts
7963
6422
  var DEFAULT_AMBIENT = [0.2, 0.2, 0.2];
7964
6423
  var DEFAULT_DIRECTION = { x: 0, y: 0, z: 1 };
7965
6424
  var DEFAULT_DIRECTION_COLOR = [0.8, 0.8, 0.8];
@@ -7998,8 +6457,8 @@ function buildMd3SurfaceGeometry(surface) {
7998
6457
  function evaluateLighting(normal, position, lighting) {
7999
6458
  const ambient = lighting?.ambient ?? DEFAULT_AMBIENT;
8000
6459
  const directional = lighting?.directional ?? { direction: DEFAULT_DIRECTION, color: DEFAULT_DIRECTION_COLOR };
8001
- const n = normalizeVec3(normal);
8002
- const l = normalizeVec3(directional.direction);
6460
+ const n = normalizeVec3$1(normal);
6461
+ const l = normalizeVec3$1(directional.direction);
8003
6462
  const ndotl = clamp012(n.x * l.x + n.y * l.y + n.z * l.z);
8004
6463
  let r = ambient[0] + directional.color[0] * ndotl;
8005
6464
  let g = ambient[1] + directional.color[1] * ndotl;
@@ -8039,7 +6498,7 @@ function buildMd3VertexData(surface, geometry, blend, lighting) {
8039
6498
  throw new Error(`Vertex index ${vertex.vertexIndex} missing for frame`);
8040
6499
  }
8041
6500
  const position = lerpVec32(vA.position, vB.position, blend.lerp);
8042
- const normal = normalizeVec3(lerpVec32(vA.normal, vB.normal, blend.lerp));
6501
+ const normal = normalizeVec3$1(lerpVec32(vA.normal, vB.normal, blend.lerp));
8043
6502
  const color = evaluateLighting(normal, position, lighting);
8044
6503
  const base = index * 12;
8045
6504
  data[base] = position.x;
@@ -8072,16 +6531,16 @@ function interpolateMd3Tag(model, blend, tagName) {
8072
6531
  throw new Error(`Tag ${tagName} is missing for one of the interpolated frames`);
8073
6532
  }
8074
6533
  const origin = lerpVec32(tagA.origin, tagB.origin, blend.lerp);
8075
- const axis0 = normalizeVec3(lerpVec32(tagA.axis[0], tagB.axis[0], blend.lerp));
8076
- const axis1 = normalizeVec3(lerpVec32(tagA.axis[1], tagB.axis[1], blend.lerp));
8077
- const axis2 = normalizeVec3(lerpVec32(tagA.axis[2], tagB.axis[2], blend.lerp));
6534
+ const axis0 = normalizeVec3$1(lerpVec32(tagA.axis[0], tagB.axis[0], blend.lerp));
6535
+ const axis1 = normalizeVec3$1(lerpVec32(tagA.axis[1], tagB.axis[1], blend.lerp));
6536
+ normalizeVec3$1(lerpVec32(tagA.axis[2], tagB.axis[2], blend.lerp));
8078
6537
  const corrected0 = axis0;
8079
- const corrected1 = normalizeVec3({
6538
+ const corrected1 = normalizeVec3$1({
8080
6539
  x: axis1.x - corrected0.x * (corrected0.x * axis1.x + corrected0.y * axis1.y + corrected0.z * axis1.z),
8081
6540
  y: axis1.y - corrected0.y * (corrected0.x * axis1.x + corrected0.y * axis1.y + corrected0.z * axis1.z),
8082
6541
  z: axis1.z - corrected0.z * (corrected0.x * axis1.x + corrected0.y * axis1.y + corrected0.z * axis1.z)
8083
6542
  });
8084
- const corrected2 = normalizeVec3({
6543
+ const corrected2 = normalizeVec3$1({
8085
6544
  x: corrected0.y * corrected1.z - corrected0.z * corrected1.y,
8086
6545
  y: corrected0.z * corrected1.x - corrected0.x * corrected1.z,
8087
6546
  z: corrected0.x * corrected1.y - corrected0.y * corrected1.x
@@ -8814,8 +7273,6 @@ function spawnRailTrail(context) {
8814
7273
  blendMode: "additive",
8815
7274
  fade: true
8816
7275
  });
8817
- const radius = 3;
8818
- const theta = d * 0.5;
8819
7276
  system.spawn({
8820
7277
  position: {
8821
7278
  x: x + (system.rng.frandom() - 0.5) * 6,
@@ -9014,8 +7471,6 @@ var SpriteRenderer = class {
9014
7471
  this.draw(x, y, width, height, 0, 0, 1, 1, color);
9015
7472
  }
9016
7473
  };
9017
-
9018
- // src/demo/demoReader.ts
9019
7474
  var DemoReader = class {
9020
7475
  constructor(buffer) {
9021
7476
  this.messageOffsets = [];
@@ -9107,7 +7562,7 @@ var DemoReader = class {
9107
7562
  */
9108
7563
  readAllBlocksToBuffer() {
9109
7564
  let totalLength = 0;
9110
- const currentOffset = this.offset;
7565
+ this.offset;
9111
7566
  const blockInfos = [];
9112
7567
  let tempOffset = this.offset;
9113
7568
  while (tempOffset + 4 <= this.buffer.byteLength) {
@@ -11374,14 +9829,11 @@ var Deflate_1$1 = Deflate$1;
11374
9829
  var deflate_2 = deflate$1;
11375
9830
  var deflateRaw_1$1 = deflateRaw$1;
11376
9831
  var gzip_1$1 = gzip$1;
11377
- var constants$1 = constants$2;
11378
9832
  var deflate_1$1 = {
11379
9833
  Deflate: Deflate_1$1,
11380
9834
  deflate: deflate_2,
11381
9835
  deflateRaw: deflateRaw_1$1,
11382
- gzip: gzip_1$1,
11383
- constants: constants$1
11384
- };
9836
+ gzip: gzip_1$1};
11385
9837
  var BAD$1 = 16209;
11386
9838
  var TYPE$1 = 16191;
11387
9839
  var inffast = function inflate_fast(strm, start) {
@@ -13331,14 +11783,11 @@ var Inflate_1$1 = Inflate$1;
13331
11783
  var inflate_2 = inflate$1;
13332
11784
  var inflateRaw_1$1 = inflateRaw$1;
13333
11785
  var ungzip$1 = inflate$1;
13334
- var constants = constants$2;
13335
11786
  var inflate_1$1 = {
13336
11787
  Inflate: Inflate_1$1,
13337
11788
  inflate: inflate_2,
13338
11789
  inflateRaw: inflateRaw_1$1,
13339
- ungzip: ungzip$1,
13340
- constants
13341
- };
11790
+ ungzip: ungzip$1};
13342
11791
  var { Deflate, deflate, deflateRaw, gzip } = deflate_1$1;
13343
11792
  var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
13344
11793
  var Deflate_1 = Deflate;
@@ -13563,41 +12012,41 @@ var StreamingBuffer = _StreamingBuffer;
13563
12012
 
13564
12013
  // src/demo/parser.ts
13565
12014
  var PROTOCOL_VERSION_RERELEASE = 2023;
13566
- var U_ORIGIN12 = 1 << 0;
13567
- var U_ORIGIN22 = 1 << 1;
13568
- var U_ANGLE22 = 1 << 2;
13569
- var U_ANGLE32 = 1 << 3;
13570
- var U_FRAME82 = 1 << 4;
13571
- var U_EVENT2 = 1 << 5;
13572
- var U_REMOVE2 = 1 << 6;
13573
- var U_MOREBITS12 = 1 << 7;
13574
- var U_NUMBER162 = 1 << 8;
13575
- var U_ORIGIN32 = 1 << 9;
13576
- var U_ANGLE12 = 1 << 10;
13577
- var U_MODEL5 = 1 << 11;
13578
- var U_RENDERFX82 = 1 << 12;
13579
- var U_ALPHA2 = 1 << 13;
13580
- var U_EFFECTS82 = 1 << 14;
13581
- var U_MOREBITS22 = 1 << 15;
13582
- var U_SKIN82 = 1 << 16;
13583
- var U_FRAME162 = 1 << 17;
13584
- var U_RENDERFX162 = 1 << 18;
13585
- var U_EFFECTS162 = 1 << 19;
13586
- var U_MODEL22 = 1 << 20;
13587
- var U_MODEL32 = 1 << 21;
13588
- var U_MODEL42 = 1 << 22;
13589
- var U_MOREBITS32 = 1 << 23;
13590
- var U_OLDORIGIN2 = 1 << 24;
13591
- var U_SKIN162 = 1 << 25;
13592
- var U_SOUND2 = 1 << 26;
13593
- var U_SOLID2 = 1 << 27;
13594
- var U_SCALE2 = 1 << 28;
13595
- var U_INSTANCE_BITS2 = 1 << 29;
13596
- var U_LOOP_VOLUME2 = 1 << 30;
13597
- var U_MOREBITS42 = 2147483648 | 0;
13598
- var U_LOOP_ATTENUATION_HIGH2 = 1 << 0;
13599
- var U_OWNER_HIGH2 = 1 << 1;
13600
- var U_OLD_FRAME_HIGH2 = 1 << 2;
12015
+ var U_ORIGIN1 = 1 << 0;
12016
+ var U_ORIGIN2 = 1 << 1;
12017
+ var U_ANGLE2 = 1 << 2;
12018
+ var U_ANGLE3 = 1 << 3;
12019
+ var U_FRAME8 = 1 << 4;
12020
+ var U_EVENT = 1 << 5;
12021
+ var U_REMOVE = 1 << 6;
12022
+ var U_MOREBITS1 = 1 << 7;
12023
+ var U_NUMBER16 = 1 << 8;
12024
+ var U_ORIGIN3 = 1 << 9;
12025
+ var U_ANGLE1 = 1 << 10;
12026
+ var U_MODEL = 1 << 11;
12027
+ var U_RENDERFX8 = 1 << 12;
12028
+ var U_ALPHA = 1 << 13;
12029
+ var U_EFFECTS8 = 1 << 14;
12030
+ var U_MOREBITS2 = 1 << 15;
12031
+ var U_SKIN8 = 1 << 16;
12032
+ var U_FRAME16 = 1 << 17;
12033
+ var U_RENDERFX16 = 1 << 18;
12034
+ var U_EFFECTS16 = 1 << 19;
12035
+ var U_MODEL2 = 1 << 20;
12036
+ var U_MODEL3 = 1 << 21;
12037
+ var U_MODEL4 = 1 << 22;
12038
+ var U_MOREBITS3 = 1 << 23;
12039
+ var U_OLDORIGIN = 1 << 24;
12040
+ var U_SKIN16 = 1 << 25;
12041
+ var U_SOUND = 1 << 26;
12042
+ var U_SOLID = 1 << 27;
12043
+ var U_SCALE = 1 << 28;
12044
+ var U_INSTANCE_BITS = 1 << 29;
12045
+ var U_LOOP_VOLUME = 1 << 30;
12046
+ var U_MOREBITS4 = 2147483648 | 0;
12047
+ var U_LOOP_ATTENUATION_HIGH = 1 << 0;
12048
+ var U_OWNER_HIGH = 1 << 1;
12049
+ var U_OLD_FRAME_HIGH = 1 << 2;
13601
12050
  var RECORD_CLIENT = 1;
13602
12051
  var RECORD_SERVER = 2;
13603
12052
  var RECORD_RELAY = 128;
@@ -13981,7 +12430,7 @@ var NetworkMessageParser = class _NetworkMessageParser {
13981
12430
  }
13982
12431
  parseConfigBlast() {
13983
12432
  const compressedSize = this.stream.readShort();
13984
- const uncompressedSize = this.stream.readShort();
12433
+ this.stream.readShort();
13985
12434
  const compressedData = this.stream.readData(compressedSize);
13986
12435
  try {
13987
12436
  const decompressed = pako.inflate(compressedData);
@@ -13997,7 +12446,7 @@ var NetworkMessageParser = class _NetworkMessageParser {
13997
12446
  }
13998
12447
  parseSpawnBaselineBlast() {
13999
12448
  const compressedSize = this.stream.readShort();
14000
- const uncompressedSize = this.stream.readShort();
12449
+ this.stream.readShort();
14001
12450
  const compressedData = this.stream.readData(compressedSize);
14002
12451
  try {
14003
12452
  const decompressed = pako.inflate(compressedData);
@@ -14024,23 +12473,23 @@ var NetworkMessageParser = class _NetworkMessageParser {
14024
12473
  if (this.handler?.onWaitingForPlayers) this.handler.onWaitingForPlayers(count);
14025
12474
  }
14026
12475
  parseBotChat() {
14027
- const botName = this.stream.readString();
14028
- const clientIndex = this.stream.readShort();
12476
+ this.stream.readString();
12477
+ this.stream.readShort();
14029
12478
  const locString = this.stream.readString();
14030
12479
  if (this.handler?.onBotChat) this.handler.onBotChat(locString);
14031
12480
  }
14032
12481
  parsePoi() {
14033
- const key = this.stream.readShort();
14034
- const time = this.stream.readShort();
12482
+ this.stream.readShort();
12483
+ this.stream.readShort();
14035
12484
  const pos = { x: 0, y: 0, z: 0 };
14036
12485
  this.readPos(pos);
14037
- const imageIndex = this.stream.readShort();
14038
- const paletteIndex = this.stream.readByte();
12486
+ this.stream.readShort();
12487
+ this.stream.readByte();
14039
12488
  const flags = this.stream.readByte();
14040
12489
  if (this.handler?.onPoi) this.handler.onPoi(flags, pos);
14041
12490
  }
14042
12491
  parseHelpPath() {
14043
- const start = this.stream.readByte();
12492
+ this.stream.readByte();
14044
12493
  const pos = { x: 0, y: 0, z: 0 };
14045
12494
  this.readPos(pos);
14046
12495
  const dir = { x: 0, y: 0, z: 0 };
@@ -14392,12 +12841,12 @@ var NetworkMessageParser = class _NetworkMessageParser {
14392
12841
  const entities = [];
14393
12842
  while (true) {
14394
12843
  const bits = this.parseEntityBits();
14395
- if (bits.bits & U_REMOVE2) {
12844
+ if (bits.bits & U_REMOVE) {
14396
12845
  if (bits.number === 0) break;
14397
12846
  continue;
14398
12847
  }
14399
12848
  const entity = createEmptyEntityState();
14400
- const forceParse = bits.number === 0 && !(bits.bits & U_MOREBITS12);
12849
+ const forceParse = bits.number === 0 && !(bits.bits & U_MOREBITS1);
14401
12850
  if (bits.number !== 0 || forceParse) {
14402
12851
  this.parseDelta(createEmptyEntityState(), entity, bits.number, bits.bits, bits.bitsHigh);
14403
12852
  }
@@ -14408,15 +12857,15 @@ var NetworkMessageParser = class _NetworkMessageParser {
14408
12857
  }
14409
12858
  parseEntityBits() {
14410
12859
  let total = this.stream.readByte();
14411
- if (total & U_MOREBITS12) total |= this.stream.readByte() << 8;
14412
- if (total & U_MOREBITS22) total |= this.stream.readByte() << 16;
14413
- if (total & U_MOREBITS32) total |= this.stream.readByte() << 24;
12860
+ if (total & U_MOREBITS1) total |= this.stream.readByte() << 8;
12861
+ if (total & U_MOREBITS2) total |= this.stream.readByte() << 16;
12862
+ if (total & U_MOREBITS3) total |= this.stream.readByte() << 24;
14414
12863
  let bitsHigh = 0;
14415
12864
  if (this.protocolVersion === PROTOCOL_VERSION_RERELEASE) {
14416
- if (total & U_MOREBITS42) bitsHigh = this.stream.readByte();
12865
+ if (total & U_MOREBITS4) bitsHigh = this.stream.readByte();
14417
12866
  }
14418
12867
  let number;
14419
- if (total & U_NUMBER162) number = this.stream.readShort();
12868
+ if (total & U_NUMBER16) number = this.stream.readShort();
14420
12869
  else number = this.stream.readByte();
14421
12870
  return { number, bits: total, bitsHigh };
14422
12871
  }
@@ -14452,40 +12901,40 @@ var NetworkMessageParser = class _NetworkMessageParser {
14452
12901
  to.number = number;
14453
12902
  to.bits = bits;
14454
12903
  to.bitsHigh = bitsHigh;
14455
- if (bits & U_MODEL5) to.modelindex = this.stream.readByte();
14456
- if (bits & U_MODEL22) to.modelindex2 = this.stream.readByte();
14457
- if (bits & U_MODEL32) to.modelindex3 = this.stream.readByte();
14458
- if (bits & U_MODEL42) to.modelindex4 = this.stream.readByte();
14459
- if (bits & U_FRAME82) to.frame = this.stream.readByte();
14460
- if (bits & U_FRAME162) to.frame = this.stream.readShort();
14461
- if (bits & U_SKIN82 && bits & U_SKIN162) to.skinnum = this.stream.readLong();
14462
- else if (bits & U_SKIN82) to.skinnum = this.stream.readByte();
14463
- else if (bits & U_SKIN162) to.skinnum = this.stream.readShort();
14464
- if (bits & U_EFFECTS82 && bits & U_EFFECTS162) to.effects = this.stream.readLong();
14465
- else if (bits & U_EFFECTS82) to.effects = this.stream.readByte();
14466
- else if (bits & U_EFFECTS162) to.effects = this.stream.readShort();
14467
- if (bits & U_RENDERFX82 && bits & U_RENDERFX162) to.renderfx = this.stream.readLong();
14468
- else if (bits & U_RENDERFX82) to.renderfx = this.stream.readByte();
14469
- else if (bits & U_RENDERFX162) to.renderfx = this.stream.readShort();
14470
- if (bits & U_ORIGIN12) to.origin.x = this.readCoord();
14471
- if (bits & U_ORIGIN22) to.origin.y = this.readCoord();
14472
- if (bits & U_ORIGIN32) to.origin.z = this.readCoord();
14473
- if (bits & U_ANGLE12) to.angles.x = this.readAngle();
14474
- if (bits & U_ANGLE22) to.angles.y = this.readAngle();
14475
- if (bits & U_ANGLE32) to.angles.z = this.readAngle();
14476
- if (bits & U_OLDORIGIN2) this.readPos(to.old_origin);
14477
- if (bits & U_SOUND2) to.sound = this.stream.readByte();
14478
- if (bits & U_EVENT2) to.event = this.stream.readByte();
12904
+ if (bits & U_MODEL) to.modelindex = this.stream.readByte();
12905
+ if (bits & U_MODEL2) to.modelindex2 = this.stream.readByte();
12906
+ if (bits & U_MODEL3) to.modelindex3 = this.stream.readByte();
12907
+ if (bits & U_MODEL4) to.modelindex4 = this.stream.readByte();
12908
+ if (bits & U_FRAME8) to.frame = this.stream.readByte();
12909
+ if (bits & U_FRAME16) to.frame = this.stream.readShort();
12910
+ if (bits & U_SKIN8 && bits & U_SKIN16) to.skinnum = this.stream.readLong();
12911
+ else if (bits & U_SKIN8) to.skinnum = this.stream.readByte();
12912
+ else if (bits & U_SKIN16) to.skinnum = this.stream.readShort();
12913
+ if (bits & U_EFFECTS8 && bits & U_EFFECTS16) to.effects = this.stream.readLong();
12914
+ else if (bits & U_EFFECTS8) to.effects = this.stream.readByte();
12915
+ else if (bits & U_EFFECTS16) to.effects = this.stream.readShort();
12916
+ if (bits & U_RENDERFX8 && bits & U_RENDERFX16) to.renderfx = this.stream.readLong();
12917
+ else if (bits & U_RENDERFX8) to.renderfx = this.stream.readByte();
12918
+ else if (bits & U_RENDERFX16) to.renderfx = this.stream.readShort();
12919
+ if (bits & U_ORIGIN1) to.origin.x = this.readCoord();
12920
+ if (bits & U_ORIGIN2) to.origin.y = this.readCoord();
12921
+ if (bits & U_ORIGIN3) to.origin.z = this.readCoord();
12922
+ if (bits & U_ANGLE1) to.angles.x = this.readAngle();
12923
+ if (bits & U_ANGLE2) to.angles.y = this.readAngle();
12924
+ if (bits & U_ANGLE3) to.angles.z = this.readAngle();
12925
+ if (bits & U_OLDORIGIN) this.readPos(to.old_origin);
12926
+ if (bits & U_SOUND) to.sound = this.stream.readByte();
12927
+ if (bits & U_EVENT) to.event = this.stream.readByte();
14479
12928
  else to.event = 0;
14480
- if (bits & U_SOLID2) to.solid = this.stream.readShort();
12929
+ if (bits & U_SOLID) to.solid = this.stream.readShort();
14481
12930
  if (this.protocolVersion === PROTOCOL_VERSION_RERELEASE) {
14482
- if (bits & U_ALPHA2) to.alpha = this.stream.readByte() / 255;
14483
- if (bits & U_SCALE2) to.scale = this.stream.readFloat();
14484
- if (bits & U_INSTANCE_BITS2) to.instanceBits = this.stream.readLong();
14485
- if (bits & U_LOOP_VOLUME2) to.loopVolume = this.stream.readByte() / 255;
14486
- if (bitsHigh & U_LOOP_ATTENUATION_HIGH2) to.loopAttenuation = this.stream.readByte() / 255;
14487
- if (bitsHigh & U_OWNER_HIGH2) to.owner = this.stream.readShort();
14488
- if (bitsHigh & U_OLD_FRAME_HIGH2) to.oldFrame = this.stream.readShort();
12931
+ if (bits & U_ALPHA) to.alpha = this.stream.readByte() / 255;
12932
+ if (bits & U_SCALE) to.scale = this.stream.readFloat();
12933
+ if (bits & U_INSTANCE_BITS) to.instanceBits = this.stream.readLong();
12934
+ if (bits & U_LOOP_VOLUME) to.loopVolume = this.stream.readByte() / 255;
12935
+ if (bitsHigh & U_LOOP_ATTENUATION_HIGH) to.loopAttenuation = this.stream.readByte() / 255;
12936
+ if (bitsHigh & U_OWNER_HIGH) to.owner = this.stream.readShort();
12937
+ if (bitsHigh & U_OLD_FRAME_HIGH) to.oldFrame = this.stream.readShort();
14489
12938
  }
14490
12939
  }
14491
12940
  };
@@ -14577,8 +13026,7 @@ var DemoAnalyzer = class {
14577
13026
  }
14578
13027
  }
14579
13028
  this.activeEntities = currentFrameEntities;
14580
- if (frame.playerState && this.header) {
14581
- }
13029
+ if (frame.playerState && this.header) ;
14582
13030
  },
14583
13031
  onPrint: (level, msg) => {
14584
13032
  const text = msg.replace(/\n/g, " ").trim();
@@ -14958,8 +13406,7 @@ var DemoPlaybackController = class {
14958
13406
  playRange(start, end) {
14959
13407
  const startFrame = start.type === "frame" ? start.frame : this.timeToFrame(start.seconds);
14960
13408
  const endFrame = end.type === "frame" ? end.frame : this.timeToFrame(end.seconds);
14961
- const totalFrames = this.getTotalFrames();
14962
- const maxFrame = Math.max(0, totalFrames - 1);
13409
+ this.getTotalFrames();
14963
13410
  if (startFrame < 0) {
14964
13411
  throw new Error(`Invalid start offset: ${startFrame}`);
14965
13412
  }
@@ -15035,8 +13482,7 @@ var DemoPlaybackController = class {
15035
13482
  }
15036
13483
  }
15037
13484
  while (this.currentFrameIndex < frameNumber) {
15038
- if (this.callbacks?.onCaptureSnapshot && (this.currentFrameIndex + 1) % this.snapshotInterval === 0) {
15039
- }
13485
+ if (this.callbacks?.onCaptureSnapshot && (this.currentFrameIndex + 1) % this.snapshotInterval === 0) ;
15040
13486
  if (!this.processNextFrame()) {
15041
13487
  break;
15042
13488
  }
@@ -15265,8 +13711,7 @@ var DemoPlaybackController = class {
15265
13711
  if (!header) return null;
15266
13712
  const serverInfo = this.getDemoServerInfo();
15267
13713
  let playerName = "Unknown";
15268
- if (this.cachedConfigStrings) {
15269
- }
13714
+ if (this.cachedConfigStrings) ;
15270
13715
  return {
15271
13716
  mapName: header.levelName,
15272
13717
  playerName,
@@ -15387,7 +13832,7 @@ var DemoPlaybackController = class {
15387
13832
  async playRangeWithTracking(start, end, tracker, options = {}) {
15388
13833
  this.tracker = tracker;
15389
13834
  tracker.startTracking();
15390
- const startFrame = start.type === "frame" ? start.frame : this.timeToFrame(start.seconds);
13835
+ start.type === "frame" ? start.frame : this.timeToFrame(start.seconds);
15391
13836
  const endFrame = end.type === "frame" ? end.frame : this.timeToFrame(end.seconds);
15392
13837
  if (options.fastForward) {
15393
13838
  try {
@@ -15445,8 +13890,6 @@ var DemoPlaybackController = class {
15445
13890
  }
15446
13891
  }
15447
13892
  };
15448
-
15449
- // src/demo/recorder.ts
15450
13893
  var DemoRecorder = class {
15451
13894
  // -1 means start of demo
15452
13895
  constructor() {
@@ -15485,8 +13928,6 @@ var DemoRecorder = class {
15485
13928
  return this.isRecording;
15486
13929
  }
15487
13930
  };
15488
-
15489
- // src/demo/writer.ts
15490
13931
  var PROTO34_REVERSE_MAP = {
15491
13932
  [ServerCommand.bad]: 0,
15492
13933
  [ServerCommand.nop]: 1,
@@ -15863,102 +14304,100 @@ var MessageWriter = class {
15863
14304
  bits = to.bits;
15864
14305
  bitsHigh = to.bitsHigh;
15865
14306
  } else {
15866
- if (to.modelindex !== 0) bits |= U_MODEL5;
15867
- if (to.modelindex2 !== 0) bits |= U_MODEL22;
15868
- if (to.modelindex3 !== 0) bits |= U_MODEL32;
15869
- if (to.modelindex4 !== 0) bits |= U_MODEL42;
14307
+ if (to.modelindex !== 0) bits |= U_MODEL;
14308
+ if (to.modelindex2 !== 0) bits |= U_MODEL2;
14309
+ if (to.modelindex3 !== 0) bits |= U_MODEL3;
14310
+ if (to.modelindex4 !== 0) bits |= U_MODEL4;
15870
14311
  if (to.frame !== 0) {
15871
- if (to.frame >= 256) bits |= U_FRAME162;
15872
- else bits |= U_FRAME82;
14312
+ if (to.frame >= 256) bits |= U_FRAME16;
14313
+ else bits |= U_FRAME8;
15873
14314
  }
15874
14315
  if (to.skinnum !== 0) {
15875
- if (to.skinnum >= 256) bits |= U_SKIN162;
15876
- else bits |= U_SKIN82;
14316
+ if (to.skinnum >= 256) bits |= U_SKIN16;
14317
+ else bits |= U_SKIN8;
15877
14318
  }
15878
14319
  if (to.effects !== 0) {
15879
- if (to.effects >= 256) bits |= U_EFFECTS162;
15880
- else bits |= U_EFFECTS82;
14320
+ if (to.effects >= 256) bits |= U_EFFECTS16;
14321
+ else bits |= U_EFFECTS8;
15881
14322
  }
15882
14323
  if (to.renderfx !== 0) {
15883
- if (to.renderfx >= 256) bits |= U_RENDERFX162;
15884
- else bits |= U_RENDERFX82;
15885
- }
15886
- if (to.origin.x !== 0) bits |= U_ORIGIN12;
15887
- if (to.origin.y !== 0) bits |= U_ORIGIN22;
15888
- if (to.origin.z !== 0) bits |= U_ORIGIN32;
15889
- if (to.angles.x !== 0) bits |= U_ANGLE12;
15890
- if (to.angles.y !== 0) bits |= U_ANGLE22;
15891
- if (to.angles.z !== 0) bits |= U_ANGLE32;
15892
- if (to.old_origin.x !== 0 || to.old_origin.y !== 0 || to.old_origin.z !== 0) bits |= U_OLDORIGIN2;
15893
- if (to.sound !== 0) bits |= U_SOUND2;
15894
- if (to.event !== 0) bits |= U_EVENT2;
15895
- if (to.solid !== 0) bits |= U_SOLID2;
14324
+ if (to.renderfx >= 256) bits |= U_RENDERFX16;
14325
+ else bits |= U_RENDERFX8;
14326
+ }
14327
+ if (to.origin.x !== 0) bits |= U_ORIGIN1;
14328
+ if (to.origin.y !== 0) bits |= U_ORIGIN2;
14329
+ if (to.origin.z !== 0) bits |= U_ORIGIN3;
14330
+ if (to.angles.x !== 0) bits |= U_ANGLE1;
14331
+ if (to.angles.y !== 0) bits |= U_ANGLE2;
14332
+ if (to.angles.z !== 0) bits |= U_ANGLE3;
14333
+ if (to.old_origin.x !== 0 || to.old_origin.y !== 0 || to.old_origin.z !== 0) bits |= U_OLDORIGIN;
14334
+ if (to.sound !== 0) bits |= U_SOUND;
14335
+ if (to.event !== 0) bits |= U_EVENT;
14336
+ if (to.solid !== 0) bits |= U_SOLID;
15896
14337
  if (protocolVersion >= 2023) {
15897
- if (to.alpha !== 0) bits |= U_ALPHA2;
15898
- if (to.scale !== 0) bits |= U_SCALE2;
15899
- if (to.instanceBits !== 0) bits |= U_INSTANCE_BITS2;
15900
- if (to.loopVolume !== 0) bits |= U_LOOP_VOLUME2;
15901
- if (to.loopAttenuation !== 0) bitsHigh |= U_LOOP_ATTENUATION_HIGH2;
15902
- if (to.owner !== 0) bitsHigh |= U_OWNER_HIGH2;
15903
- if (to.oldFrame !== 0) bitsHigh |= U_OLD_FRAME_HIGH2;
15904
- }
15905
- if (to.number >= 256) bits |= U_NUMBER162;
15906
- }
15907
- if (bitsHigh !== 0) bits |= U_MOREBITS42;
15908
- if ((bits & 4278190080) !== 0) bits |= U_MOREBITS32;
15909
- if ((bits & 16711680) !== 0) bits |= U_MOREBITS22;
15910
- if ((bits & 65280) !== 0) bits |= U_MOREBITS12;
14338
+ if (to.alpha !== 0) bits |= U_ALPHA;
14339
+ if (to.scale !== 0) bits |= U_SCALE;
14340
+ if (to.instanceBits !== 0) bits |= U_INSTANCE_BITS;
14341
+ if (to.loopVolume !== 0) bits |= U_LOOP_VOLUME;
14342
+ if (to.loopAttenuation !== 0) bitsHigh |= U_LOOP_ATTENUATION_HIGH;
14343
+ if (to.owner !== 0) bitsHigh |= U_OWNER_HIGH;
14344
+ if (to.oldFrame !== 0) bitsHigh |= U_OLD_FRAME_HIGH;
14345
+ }
14346
+ if (to.number >= 256) bits |= U_NUMBER16;
14347
+ }
14348
+ if (bitsHigh !== 0) bits |= U_MOREBITS4;
14349
+ if ((bits & 4278190080) !== 0) bits |= U_MOREBITS3;
14350
+ if ((bits & 16711680) !== 0) bits |= U_MOREBITS2;
14351
+ if ((bits & 65280) !== 0) bits |= U_MOREBITS1;
15911
14352
  this.writer.writeByte(bits & 255);
15912
- if (bits & U_MOREBITS12) this.writer.writeByte(bits >> 8 & 255);
15913
- if (bits & U_MOREBITS22) this.writer.writeByte(bits >> 16 & 255);
15914
- if (bits & U_MOREBITS32) this.writer.writeByte(bits >> 24 & 255);
15915
- if (protocolVersion >= 2023 && bits & U_MOREBITS42) {
14353
+ if (bits & U_MOREBITS1) this.writer.writeByte(bits >> 8 & 255);
14354
+ if (bits & U_MOREBITS2) this.writer.writeByte(bits >> 16 & 255);
14355
+ if (bits & U_MOREBITS3) this.writer.writeByte(bits >> 24 & 255);
14356
+ if (protocolVersion >= 2023 && bits & U_MOREBITS4) {
15916
14357
  this.writer.writeByte(bitsHigh & 255);
15917
14358
  }
15918
- if (bits & U_NUMBER162) this.writer.writeShort(to.number);
14359
+ if (bits & U_NUMBER16) this.writer.writeShort(to.number);
15919
14360
  else this.writer.writeByte(to.number);
15920
- if (bits & U_MODEL5) this.writer.writeByte(to.modelindex);
15921
- if (bits & U_MODEL22) this.writer.writeByte(to.modelindex2);
15922
- if (bits & U_MODEL32) this.writer.writeByte(to.modelindex3);
15923
- if (bits & U_MODEL42) this.writer.writeByte(to.modelindex4);
15924
- if (bits & U_FRAME82) this.writer.writeByte(to.frame);
15925
- if (bits & U_FRAME162) this.writer.writeShort(to.frame);
15926
- if (bits & U_SKIN82 && bits & U_SKIN162) this.writer.writeLong(to.skinnum);
15927
- else if (bits & U_SKIN82) this.writer.writeByte(to.skinnum);
15928
- else if (bits & U_SKIN162) this.writer.writeShort(to.skinnum);
15929
- if (bits & U_EFFECTS82 && bits & U_EFFECTS162) this.writer.writeLong(to.effects);
15930
- else if (bits & U_EFFECTS82) this.writer.writeByte(to.effects);
15931
- else if (bits & U_EFFECTS162) this.writer.writeShort(to.effects);
15932
- if (bits & U_RENDERFX82 && bits & U_RENDERFX162) this.writer.writeLong(to.renderfx);
15933
- else if (bits & U_RENDERFX82) this.writer.writeByte(to.renderfx);
15934
- else if (bits & U_RENDERFX162) this.writer.writeShort(to.renderfx);
15935
- if (bits & U_ORIGIN12) this.writer.writeCoord(to.origin.x);
15936
- if (bits & U_ORIGIN22) this.writer.writeCoord(to.origin.y);
15937
- if (bits & U_ORIGIN32) this.writer.writeCoord(to.origin.z);
15938
- if (bits & U_ANGLE12) this.writer.writeAngle(to.angles.x);
15939
- if (bits & U_ANGLE22) this.writer.writeAngle(to.angles.y);
15940
- if (bits & U_ANGLE32) this.writer.writeAngle(to.angles.z);
15941
- if (bits & U_OLDORIGIN2) {
14361
+ if (bits & U_MODEL) this.writer.writeByte(to.modelindex);
14362
+ if (bits & U_MODEL2) this.writer.writeByte(to.modelindex2);
14363
+ if (bits & U_MODEL3) this.writer.writeByte(to.modelindex3);
14364
+ if (bits & U_MODEL4) this.writer.writeByte(to.modelindex4);
14365
+ if (bits & U_FRAME8) this.writer.writeByte(to.frame);
14366
+ if (bits & U_FRAME16) this.writer.writeShort(to.frame);
14367
+ if (bits & U_SKIN8 && bits & U_SKIN16) this.writer.writeLong(to.skinnum);
14368
+ else if (bits & U_SKIN8) this.writer.writeByte(to.skinnum);
14369
+ else if (bits & U_SKIN16) this.writer.writeShort(to.skinnum);
14370
+ if (bits & U_EFFECTS8 && bits & U_EFFECTS16) this.writer.writeLong(to.effects);
14371
+ else if (bits & U_EFFECTS8) this.writer.writeByte(to.effects);
14372
+ else if (bits & U_EFFECTS16) this.writer.writeShort(to.effects);
14373
+ if (bits & U_RENDERFX8 && bits & U_RENDERFX16) this.writer.writeLong(to.renderfx);
14374
+ else if (bits & U_RENDERFX8) this.writer.writeByte(to.renderfx);
14375
+ else if (bits & U_RENDERFX16) this.writer.writeShort(to.renderfx);
14376
+ if (bits & U_ORIGIN1) this.writer.writeCoord(to.origin.x);
14377
+ if (bits & U_ORIGIN2) this.writer.writeCoord(to.origin.y);
14378
+ if (bits & U_ORIGIN3) this.writer.writeCoord(to.origin.z);
14379
+ if (bits & U_ANGLE1) this.writer.writeAngle(to.angles.x);
14380
+ if (bits & U_ANGLE2) this.writer.writeAngle(to.angles.y);
14381
+ if (bits & U_ANGLE3) this.writer.writeAngle(to.angles.z);
14382
+ if (bits & U_OLDORIGIN) {
15942
14383
  this.writer.writeCoord(to.old_origin.x);
15943
14384
  this.writer.writeCoord(to.old_origin.y);
15944
14385
  this.writer.writeCoord(to.old_origin.z);
15945
14386
  }
15946
- if (bits & U_SOUND2) this.writer.writeByte(to.sound);
15947
- if (bits & U_EVENT2) this.writer.writeByte(to.event);
15948
- if (bits & U_SOLID2) this.writer.writeShort(to.solid);
14387
+ if (bits & U_SOUND) this.writer.writeByte(to.sound);
14388
+ if (bits & U_EVENT) this.writer.writeByte(to.event);
14389
+ if (bits & U_SOLID) this.writer.writeShort(to.solid);
15949
14390
  if (protocolVersion >= 2023) {
15950
- if (bits & U_ALPHA2) this.writer.writeByte(Math.round(to.alpha * 255));
15951
- if (bits & U_SCALE2) this.writer.writeFloat(to.scale);
15952
- if (bits & U_INSTANCE_BITS2) this.writer.writeLong(to.instanceBits);
15953
- if (bits & U_LOOP_VOLUME2) this.writer.writeByte(Math.round(to.loopVolume * 255));
15954
- if (bitsHigh & U_LOOP_ATTENUATION_HIGH2) this.writer.writeByte(Math.round(to.loopAttenuation * 255));
15955
- if (bitsHigh & U_OWNER_HIGH2) this.writer.writeShort(to.owner);
15956
- if (bitsHigh & U_OLD_FRAME_HIGH2) this.writer.writeShort(to.oldFrame);
14391
+ if (bits & U_ALPHA) this.writer.writeByte(Math.round(to.alpha * 255));
14392
+ if (bits & U_SCALE) this.writer.writeFloat(to.scale);
14393
+ if (bits & U_INSTANCE_BITS) this.writer.writeLong(to.instanceBits);
14394
+ if (bits & U_LOOP_VOLUME) this.writer.writeByte(Math.round(to.loopVolume * 255));
14395
+ if (bitsHigh & U_LOOP_ATTENUATION_HIGH) this.writer.writeByte(Math.round(to.loopAttenuation * 255));
14396
+ if (bitsHigh & U_OWNER_HIGH) this.writer.writeShort(to.owner);
14397
+ if (bitsHigh & U_OLD_FRAME_HIGH) this.writer.writeShort(to.oldFrame);
15957
14398
  }
15958
14399
  }
15959
14400
  };
15960
-
15961
- // src/demo/validator.ts
15962
14401
  var DemoValidator = class {
15963
14402
  /**
15964
14403
  * Validates a Quake 2 demo file buffer.
@@ -15990,8 +14429,6 @@ var DemoValidator = class {
15990
14429
  return { valid: true, version };
15991
14430
  }
15992
14431
  };
15993
-
15994
- // src/demo/demoWriter.ts
15995
14432
  var DemoWriter = class {
15996
14433
  constructor() {
15997
14434
  this.writer = new BinaryWriter();
@@ -16013,36 +14450,36 @@ function applyEntityDelta(to, from) {
16013
14450
  const bits = from.bits;
16014
14451
  const bitsHigh = from.bitsHigh;
16015
14452
  to.number = from.number;
16016
- if (bits & U_MODEL5) to.modelindex = from.modelindex;
16017
- if (bits & U_MODEL22) to.modelindex2 = from.modelindex2;
16018
- if (bits & U_MODEL32) to.modelindex3 = from.modelindex3;
16019
- if (bits & U_MODEL42) to.modelindex4 = from.modelindex4;
16020
- if (bits & U_FRAME82) to.frame = from.frame;
16021
- if (bits & U_FRAME162) to.frame = from.frame;
16022
- if (bits & U_SKIN82 || bits & U_SKIN162) to.skinnum = from.skinnum;
16023
- if (bits & U_EFFECTS82 || bits & U_EFFECTS162) to.effects = from.effects;
16024
- if (bits & U_RENDERFX82 || bits & U_RENDERFX162) to.renderfx = from.renderfx;
16025
- if (bits & U_ORIGIN12) to.origin.x = from.origin.x;
16026
- if (bits & U_ORIGIN22) to.origin.y = from.origin.y;
16027
- if (bits & U_ORIGIN32) to.origin.z = from.origin.z;
16028
- if (bits & U_ANGLE12) to.angles.x = from.angles.x;
16029
- if (bits & U_ANGLE22) to.angles.y = from.angles.y;
16030
- if (bits & U_ANGLE32) to.angles.z = from.angles.z;
16031
- if (bits & U_OLDORIGIN2) {
14453
+ if (bits & U_MODEL) to.modelindex = from.modelindex;
14454
+ if (bits & U_MODEL2) to.modelindex2 = from.modelindex2;
14455
+ if (bits & U_MODEL3) to.modelindex3 = from.modelindex3;
14456
+ if (bits & U_MODEL4) to.modelindex4 = from.modelindex4;
14457
+ if (bits & U_FRAME8) to.frame = from.frame;
14458
+ if (bits & U_FRAME16) to.frame = from.frame;
14459
+ if (bits & U_SKIN8 || bits & U_SKIN16) to.skinnum = from.skinnum;
14460
+ if (bits & U_EFFECTS8 || bits & U_EFFECTS16) to.effects = from.effects;
14461
+ if (bits & U_RENDERFX8 || bits & U_RENDERFX16) to.renderfx = from.renderfx;
14462
+ if (bits & U_ORIGIN1) to.origin.x = from.origin.x;
14463
+ if (bits & U_ORIGIN2) to.origin.y = from.origin.y;
14464
+ if (bits & U_ORIGIN3) to.origin.z = from.origin.z;
14465
+ if (bits & U_ANGLE1) to.angles.x = from.angles.x;
14466
+ if (bits & U_ANGLE2) to.angles.y = from.angles.y;
14467
+ if (bits & U_ANGLE3) to.angles.z = from.angles.z;
14468
+ if (bits & U_OLDORIGIN) {
16032
14469
  to.old_origin.x = from.old_origin.x;
16033
14470
  to.old_origin.y = from.old_origin.y;
16034
14471
  to.old_origin.z = from.old_origin.z;
16035
14472
  }
16036
- if (bits & U_SOUND2) to.sound = from.sound;
16037
- if (bits & U_EVENT2) to.event = from.event;
16038
- if (bits & U_SOLID2) to.solid = from.solid;
16039
- if (bits & U_ALPHA2) to.alpha = from.alpha;
16040
- if (bits & U_SCALE2) to.scale = from.scale;
16041
- if (bits & U_INSTANCE_BITS2) to.instanceBits = from.instanceBits;
16042
- if (bits & U_LOOP_VOLUME2) to.loopVolume = from.loopVolume;
16043
- if (bitsHigh & U_LOOP_ATTENUATION_HIGH2) to.loopAttenuation = from.loopAttenuation;
16044
- if (bitsHigh & U_OWNER_HIGH2) to.owner = from.owner;
16045
- if (bitsHigh & U_OLD_FRAME_HIGH2) to.oldFrame = from.oldFrame;
14473
+ if (bits & U_SOUND) to.sound = from.sound;
14474
+ if (bits & U_EVENT) to.event = from.event;
14475
+ if (bits & U_SOLID) to.solid = from.solid;
14476
+ if (bits & U_ALPHA) to.alpha = from.alpha;
14477
+ if (bits & U_SCALE) to.scale = from.scale;
14478
+ if (bits & U_INSTANCE_BITS) to.instanceBits = from.instanceBits;
14479
+ if (bits & U_LOOP_VOLUME) to.loopVolume = from.loopVolume;
14480
+ if (bitsHigh & U_LOOP_ATTENUATION_HIGH) to.loopAttenuation = from.loopAttenuation;
14481
+ if (bitsHigh & U_OWNER_HIGH) to.owner = from.owner;
14482
+ if (bitsHigh & U_OLD_FRAME_HIGH) to.oldFrame = from.oldFrame;
16046
14483
  }
16047
14484
 
16048
14485
  // src/demo/clipper.ts
@@ -16119,7 +14556,7 @@ var DemoClipper = class {
16119
14556
  }
16120
14557
  }
16121
14558
  for (const deltaEnt of frame.packetEntities.entities) {
16122
- if (deltaEnt.bits & U_REMOVE2) {
14559
+ if (deltaEnt.bits & U_REMOVE) {
16123
14560
  newEntities.delete(deltaEnt.number);
16124
14561
  continue;
16125
14562
  }
@@ -16422,7 +14859,6 @@ function projectPoint(v, width, height, center, scale) {
16422
14859
  const z1 = v.z - center.z;
16423
14860
  const cosX = 0.866;
16424
14861
  const sinX = 0.5;
16425
- const y2 = y1 * cosX - z1 * sinX;
16426
14862
  const z2 = y1 * sinX + z1 * cosX;
16427
14863
  const screenX = width / 2 + x1 * scale;
16428
14864
  const screenY = height / 2 - z2 * scale;
@@ -16632,8 +15068,7 @@ function parseEntLump(text) {
16632
15068
  cursor++;
16633
15069
  const start = cursor;
16634
15070
  while (cursor < length && text[cursor] !== '"') {
16635
- if (text[cursor] === "\n") {
16636
- }
15071
+ if (text[cursor] === "\n") ;
16637
15072
  cursor++;
16638
15073
  }
16639
15074
  const token = text.substring(start, cursor);
@@ -16758,7 +15193,7 @@ async function createWebGPUContext(canvas, options) {
16758
15193
  };
16759
15194
  const device = await adapter.requestDevice(deviceDescriptor);
16760
15195
  let context;
16761
- let format = "bgra8unorm";
15196
+ let format = "rgba8unorm";
16762
15197
  let isHeadless = true;
16763
15198
  let width = 0;
16764
15199
  let height = 0;
@@ -16874,8 +15309,6 @@ async function captureRenderTarget(device, texture) {
16874
15309
  outputBuffer.unmap();
16875
15310
  return result;
16876
15311
  }
16877
-
16878
- // src/network/clientConnection.ts
16879
15312
  var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
16880
15313
  ConnectionState2[ConnectionState2["Disconnected"] = 0] = "Disconnected";
16881
15314
  ConnectionState2[ConnectionState2["Connecting"] = 1] = "Connecting";
@@ -17158,216 +15591,12 @@ function createEngine(imports) {
17158
15591
  }
17159
15592
  };
17160
15593
  }
17161
- export {
17162
- ATTN_IDLE,
17163
- ATTN_LOOP_NONE,
17164
- ATTN_NONE,
17165
- ATTN_NORM,
17166
- ATTN_STATIC,
17167
- AssetDependencyError,
17168
- AssetDependencyTracker,
17169
- AssetManager,
17170
- AssetPreviewGenerator,
17171
- AudioApi,
17172
- AudioContextController,
17173
- AudioOcclusion,
17174
- AudioRegistry,
17175
- AudioRegistryError,
17176
- AudioSystem,
17177
- BSP_SURFACE_FRAGMENT_SOURCE,
17178
- BSP_SURFACE_VERTEX_SOURCE,
17179
- BSP_VERTEX_LAYOUT,
17180
- BspLoader,
17181
- BspParseError,
17182
- BspSurfacePipeline,
17183
- Camera,
17184
- ClientConnection,
17185
- Command,
17186
- CommandRegistry,
17187
- ConfigStringRegistry,
17188
- ConnectionState,
17189
- Cvar,
17190
- CvarRegistry,
17191
- DemoAnalyzer,
17192
- DemoCameraMode,
17193
- DemoClipper,
17194
- DemoEventType,
17195
- DemoPlaybackController,
17196
- DemoReader,
17197
- DemoRecorder,
17198
- DemoValidator,
17199
- DynamicLightManager,
17200
- EngineHost,
17201
- EngineRuntime,
17202
- FileType,
17203
- FixedTimestepLoop,
17204
- Framebuffer,
17205
- IndexBuffer,
17206
- LruCache,
17207
- MAX_SOUND_CHANNELS,
17208
- MD2_FRAGMENT_SHADER,
17209
- MD2_VERTEX_SHADER,
17210
- MD3_FRAGMENT_SHADER,
17211
- MD3_VERTEX_SHADER,
17212
- MapAnalyzer,
17213
- Md2Loader,
17214
- Md2MeshBuffers,
17215
- Md2ParseError,
17216
- Md2Pipeline,
17217
- Md3Loader,
17218
- Md3ModelMesh,
17219
- Md3ParseError,
17220
- Md3Pipeline,
17221
- Md3SurfaceMesh,
17222
- MessageWriter,
17223
- MusicSystem,
17224
- NetworkMessageParser,
17225
- PARTICLE_FRAGMENT_SHADER,
17226
- PARTICLE_VERTEX_SHADER,
17227
- PROTOCOL_VERSION_RERELEASE,
17228
- PakArchive,
17229
- PakIndexStore,
17230
- PakIngestionError,
17231
- PakParseError,
17232
- PakValidationError,
17233
- PakValidator,
17234
- PakWriter,
17235
- ParticleRenderer,
17236
- ParticleSystem,
17237
- PlaybackState,
17238
- RERELEASE_KNOWN_PAKS,
17239
- ResourceLoadTracker,
17240
- ResourceType,
17241
- SKYBOX_FRAGMENT_SHADER,
17242
- SKYBOX_VERTEX_SHADER,
17243
- SOUND_FULLVOLUME,
17244
- SOUND_LOOP_ATTENUATE,
17245
- ShaderProgram,
17246
- SkyboxPipeline,
17247
- SoundChannel,
17248
- SoundPrecache,
17249
- SoundRegistry,
17250
- SpriteLoader,
17251
- SpriteParseError,
17252
- SpriteRenderer,
17253
- StreamingPakArchive,
17254
- Texture2D,
17255
- TextureCache,
17256
- TextureCubeMap,
17257
- TgaParseError,
17258
- U_ALPHA2 as U_ALPHA,
17259
- U_ANGLE12 as U_ANGLE1,
17260
- U_ANGLE22 as U_ANGLE2,
17261
- U_ANGLE32 as U_ANGLE3,
17262
- U_EFFECTS162 as U_EFFECTS16,
17263
- U_EFFECTS82 as U_EFFECTS8,
17264
- U_EVENT2 as U_EVENT,
17265
- U_FRAME162 as U_FRAME16,
17266
- U_FRAME82 as U_FRAME8,
17267
- U_INSTANCE_BITS2 as U_INSTANCE_BITS,
17268
- U_LOOP_ATTENUATION_HIGH2 as U_LOOP_ATTENUATION_HIGH,
17269
- U_LOOP_VOLUME2 as U_LOOP_VOLUME,
17270
- U_MODEL5 as U_MODEL,
17271
- U_MODEL22 as U_MODEL2,
17272
- U_MODEL32 as U_MODEL3,
17273
- U_MODEL42 as U_MODEL4,
17274
- U_OLDORIGIN2 as U_OLDORIGIN,
17275
- U_OLD_FRAME_HIGH2 as U_OLD_FRAME_HIGH,
17276
- U_ORIGIN12 as U_ORIGIN1,
17277
- U_ORIGIN22 as U_ORIGIN2,
17278
- U_ORIGIN32 as U_ORIGIN3,
17279
- U_OWNER_HIGH2 as U_OWNER_HIGH,
17280
- U_REMOVE2 as U_REMOVE,
17281
- U_RENDERFX162 as U_RENDERFX16,
17282
- U_RENDERFX82 as U_RENDERFX8,
17283
- U_SCALE2 as U_SCALE,
17284
- U_SKIN162 as U_SKIN16,
17285
- U_SKIN82 as U_SKIN8,
17286
- U_SOLID2 as U_SOLID,
17287
- U_SOUND2 as U_SOUND,
17288
- VertexArray,
17289
- VertexBuffer,
17290
- VirtualFileSystem,
17291
- advanceAnimation,
17292
- applyEntityDelta,
17293
- applySurfaceState,
17294
- attenuationToDistanceMultiplier,
17295
- boxIntersectsFrustum,
17296
- buildBspGeometry,
17297
- buildMd2Geometry,
17298
- buildMd2VertexData,
17299
- buildMd3SurfaceGeometry,
17300
- buildMd3VertexData,
17301
- calculateMaxAudibleDistance,
17302
- calculatePakChecksum,
17303
- captureRenderTarget,
17304
- computeFrameBlend,
17305
- computeSkyScroll,
17306
- createAnimationState,
17307
- createAudioGraph,
17308
- createBspSurfaces,
17309
- createEmptyEntityState,
17310
- createEmptyProtocolPlayerState,
17311
- createEngine,
17312
- createEngineRuntime,
17313
- createFaceLightmap,
17314
- createHeadlessRenderTarget,
17315
- createInitialChannels,
17316
- createOcclusionResolver,
17317
- createProgramFromSources,
17318
- createWebGLContext,
17319
- createWebGPUContext,
17320
- decodeOgg,
17321
- deriveSurfaceRenderState,
17322
- detectFileType,
17323
- extractFrustumPlanes,
17324
- filesToPakSources,
17325
- findLeafForPoint,
17326
- gatherVisibleFaces,
17327
- groupMd2Animations,
17328
- ingestPakFiles,
17329
- ingestPaks,
17330
- interpolateMd3Tag,
17331
- interpolateVec3,
17332
- isBinaryFile,
17333
- isTextFile,
17334
- parseBsp,
17335
- parseEntLump,
17336
- parseMd2,
17337
- parseMd3,
17338
- parsePcx,
17339
- parseSprite,
17340
- parseTga,
17341
- parseWal,
17342
- parseWalTexture,
17343
- parseWav,
17344
- pcxToRgba,
17345
- pickChannel,
17346
- preparePcxTexture,
17347
- queryCapabilities,
17348
- removeViewTranslation,
17349
- resolveLightStyles,
17350
- serializeEntLump,
17351
- spawnBfgExplosion,
17352
- spawnBlasterImpact,
17353
- spawnBlood,
17354
- spawnBulletImpact,
17355
- spawnExplosion,
17356
- spawnMuzzleFlash,
17357
- spawnRailTrail,
17358
- spawnSparks,
17359
- spawnSplash,
17360
- spawnSteam,
17361
- spawnTeleportFlash,
17362
- spawnTrail,
17363
- validateEntity,
17364
- walToRgba,
17365
- wireDropTarget,
17366
- wireFileInput
17367
- };
17368
15594
  /*! Bundled license information:
17369
15595
 
17370
15596
  pako/dist/pako.esm.mjs:
17371
15597
  (*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *)
17372
15598
  */
15599
+
15600
+ export { AssetDependencyError, AssetDependencyTracker, AssetManager, AssetPreviewGenerator, AudioApi, AudioContextController, AudioOcclusion, AudioRegistry, AudioRegistryError, AudioSystem, BSP_SURFACE_FRAGMENT_SOURCE, BSP_SURFACE_VERTEX_SOURCE, BSP_VERTEX_LAYOUT, BspLoader, BspParseError, BspSurfacePipeline, Camera, ClientConnection, Command, CommandRegistry, ConfigStringRegistry, ConnectionState, Cvar, CvarRegistry, DemoAnalyzer, DemoCameraMode, DemoClipper, DemoEventType, DemoPlaybackController, DemoReader, DemoRecorder, DemoValidator, DynamicLightManager, EngineHost, EngineRuntime, FileType, FixedTimestepLoop, Framebuffer, IndexBuffer, LruCache, MD2_FRAGMENT_SHADER, MD2_VERTEX_SHADER, MD3_FRAGMENT_SHADER, MD3_VERTEX_SHADER, MapAnalyzer, Md2Loader, Md2MeshBuffers, Md2ParseError, Md2Pipeline, Md3Loader, Md3ModelMesh, Md3ParseError, Md3Pipeline, Md3SurfaceMesh, MessageWriter, MusicSystem, NetworkMessageParser, PARTICLE_FRAGMENT_SHADER, PARTICLE_VERTEX_SHADER, PROTOCOL_VERSION_RERELEASE, PakArchive, PakIndexStore, PakIngestionError, PakParseError, PakValidationError, PakValidator, PakWriter, ParticleRenderer, ParticleSystem, PlaybackState, RERELEASE_KNOWN_PAKS, ResourceLoadTracker, ResourceType, SKYBOX_FRAGMENT_SHADER, SKYBOX_VERTEX_SHADER, ShaderProgram, SkyboxPipeline, SoundPrecache, SoundRegistry, SpriteLoader, SpriteParseError, SpriteRenderer, StreamingPakArchive, Texture2D, TextureCache, TextureCubeMap, TgaParseError, U_ALPHA, U_ANGLE1, U_ANGLE2, U_ANGLE3, U_EFFECTS16, U_EFFECTS8, U_EVENT, U_FRAME16, U_FRAME8, U_INSTANCE_BITS, U_LOOP_ATTENUATION_HIGH, U_LOOP_VOLUME, U_MODEL, U_MODEL2, U_MODEL3, U_MODEL4, U_OLDORIGIN, U_OLD_FRAME_HIGH, U_ORIGIN1, U_ORIGIN2, U_ORIGIN3, U_OWNER_HIGH, U_REMOVE, U_RENDERFX16, U_RENDERFX8, U_SCALE, U_SKIN16, U_SKIN8, U_SOLID, U_SOUND, VertexArray, VertexBuffer, VirtualFileSystem, advanceAnimation, applyEntityDelta, applySurfaceState, boxIntersectsFrustum, buildBspGeometry, buildMd2Geometry, buildMd2VertexData, buildMd3SurfaceGeometry, buildMd3VertexData, calculatePakChecksum, captureRenderTarget, computeFrameBlend, computeSkyScroll, createAnimationState, createAudioGraph, createBspSurfaces, createEmptyEntityState, createEmptyProtocolPlayerState, createEngine, createEngineRuntime, createFaceLightmap, createHeadlessRenderTarget, createInitialChannels, createOcclusionResolver, createProgramFromSources, createWebGLContext, createWebGPUContext, decodeOgg, deriveSurfaceRenderState, detectFileType, extractFrustumPlanes, filesToPakSources, findLeafForPoint, gatherVisibleFaces, groupMd2Animations, ingestPakFiles, ingestPaks, interpolateMd3Tag, interpolateVec3, isBinaryFile, isTextFile, parseBsp, parseEntLump, parseMd2, parseMd3, parsePcx, parseSprite, parseTga, parseWal, parseWalTexture, parseWav, pcxToRgba, pickChannel, preparePcxTexture, queryCapabilities, removeViewTranslation, resolveLightStyles, serializeEntLump, spawnBfgExplosion, spawnBlasterImpact, spawnBlood, spawnBulletImpact, spawnExplosion, spawnMuzzleFlash, spawnRailTrail, spawnSparks, spawnSplash, spawnSteam, spawnTeleportFlash, spawnTrail, validateEntity, walToRgba, wireDropTarget, wireFileInput };
15601
+ //# sourceMappingURL=index.js.map
17373
15602
  //# sourceMappingURL=index.js.map