quake2ts 0.0.543 → 0.0.544

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.
Files changed (27) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +17 -17
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +264 -6
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +264 -6
  7. package/packages/client/dist/esm/index.js.map +1 -1
  8. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  9. package/packages/client/dist/types/effects-system.d.ts +1 -1
  10. package/packages/client/dist/types/effects-system.d.ts.map +1 -1
  11. package/packages/engine/dist/browser/index.global.js +15 -15
  12. package/packages/engine/dist/browser/index.global.js.map +1 -1
  13. package/packages/engine/dist/cjs/index.cjs +388 -46
  14. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  15. package/packages/engine/dist/esm/index.js +384 -46
  16. package/packages/engine/dist/esm/index.js.map +1 -1
  17. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  18. package/packages/engine/dist/types/assets/visibilityAnalyzer.d.ts +17 -0
  19. package/packages/engine/dist/types/assets/visibilityAnalyzer.d.ts.map +1 -0
  20. package/packages/engine/dist/types/demo/parser.d.ts.map +1 -1
  21. package/packages/engine/dist/types/demo/writer.d.ts +13 -12
  22. package/packages/engine/dist/types/demo/writer.d.ts.map +1 -1
  23. package/packages/engine/dist/types/index.d.ts +1 -1
  24. package/packages/engine/dist/types/index.d.ts.map +1 -1
  25. package/packages/engine/dist/types/render/particleSystem.d.ts +16 -0
  26. package/packages/engine/dist/types/render/particleSystem.d.ts.map +1 -1
  27. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
@@ -200,10 +200,14 @@ __export(index_exports, {
200
200
  removeViewTranslation: () => removeViewTranslation,
201
201
  resolveLightStyles: () => resolveLightStyles,
202
202
  serializeEntLump: () => serializeEntLump,
203
+ spawnBfgExplosion: () => spawnBfgExplosion,
204
+ spawnBlasterImpact: () => spawnBlasterImpact,
203
205
  spawnBlood: () => spawnBlood,
204
206
  spawnBulletImpact: () => spawnBulletImpact,
205
207
  spawnExplosion: () => spawnExplosion,
206
208
  spawnMuzzleFlash: () => spawnMuzzleFlash,
209
+ spawnRailTrail: () => spawnRailTrail,
210
+ spawnSparks: () => spawnSparks,
207
211
  spawnSplash: () => spawnSplash,
208
212
  spawnSteam: () => spawnSteam,
209
213
  spawnTeleportFlash: () => spawnTeleportFlash,
@@ -8432,6 +8436,137 @@ function spawnSteam(context) {
8432
8436
  });
8433
8437
  }
8434
8438
  }
8439
+ function spawnRailTrail(context) {
8440
+ const { system, start, end } = context;
8441
+ const dx = end.x - start.x;
8442
+ const dy = end.y - start.y;
8443
+ const dz = end.z - start.z;
8444
+ const dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
8445
+ if (dist < 1) return;
8446
+ const dir = { x: dx / dist, y: dy / dist, z: dz / dist };
8447
+ const step = 8;
8448
+ for (let d = 0; d < dist; d += step) {
8449
+ const x = start.x + dir.x * d;
8450
+ const y = start.y + dir.y * d;
8451
+ const z = start.z + dir.z * d;
8452
+ system.spawn({
8453
+ position: { x, y, z },
8454
+ velocity: { x: 0, y: 0, z: 0 },
8455
+ // Static
8456
+ color: [0.4, 0.4, 1, 0.8],
8457
+ size: 2,
8458
+ lifetime: 0.6,
8459
+ blendMode: "additive",
8460
+ fade: true
8461
+ });
8462
+ const radius = 3;
8463
+ const theta = d * 0.5;
8464
+ system.spawn({
8465
+ position: {
8466
+ x: x + (system.rng.frandom() - 0.5) * 6,
8467
+ y: y + (system.rng.frandom() - 0.5) * 6,
8468
+ z: z + (system.rng.frandom() - 0.5) * 6
8469
+ },
8470
+ velocity: {
8471
+ x: (system.rng.frandom() - 0.5) * 10,
8472
+ y: (system.rng.frandom() - 0.5) * 10,
8473
+ z: (system.rng.frandom() - 0.5) * 10
8474
+ },
8475
+ color: [0.1, 0.1, 0.8, 0.6],
8476
+ size: 3,
8477
+ lifetime: 0.8 + system.rng.frandom() * 0.2,
8478
+ blendMode: "additive",
8479
+ fade: true
8480
+ });
8481
+ }
8482
+ }
8483
+ function spawnSparks(context) {
8484
+ const { system, origin, normal = { x: 0, y: 0, z: 1 }, count = 12, color = [1, 0.9, 0.2, 1] } = context;
8485
+ for (let i = 0; i < count; i++) {
8486
+ const speed = 100 + system.rng.frandom() * 200;
8487
+ const spread = 0.5;
8488
+ system.spawn({
8489
+ position: origin,
8490
+ velocity: {
8491
+ x: normal.x * speed + (system.rng.frandom() - 0.5) * 100 * spread,
8492
+ y: normal.y * speed + (system.rng.frandom() - 0.5) * 100 * spread,
8493
+ z: normal.z * speed + (system.rng.frandom() - 0.5) * 100 * spread
8494
+ },
8495
+ color,
8496
+ size: 1.5,
8497
+ lifetime: 0.3 + system.rng.frandom() * 0.2,
8498
+ gravity: 800,
8499
+ bounce: 0.5,
8500
+ damping: 1,
8501
+ blendMode: "additive",
8502
+ fade: true
8503
+ });
8504
+ }
8505
+ }
8506
+ function spawnBlasterImpact(context) {
8507
+ const { system, origin, normal = { x: 0, y: 0, z: 1 }, color = [1, 0.8, 0, 1] } = context;
8508
+ system.spawn({
8509
+ position: origin,
8510
+ velocity: { x: 0, y: 0, z: 0 },
8511
+ color,
8512
+ size: 8,
8513
+ lifetime: 0.2,
8514
+ blendMode: "additive",
8515
+ fade: true
8516
+ });
8517
+ for (let i = 0; i < 8; i++) {
8518
+ const speed = 150 + system.rng.frandom() * 150;
8519
+ system.spawn({
8520
+ position: origin,
8521
+ velocity: {
8522
+ x: normal.x * speed + (system.rng.frandom() - 0.5) * 120,
8523
+ y: normal.y * speed + (system.rng.frandom() - 0.5) * 120,
8524
+ z: normal.z * speed + (system.rng.frandom() - 0.5) * 120
8525
+ },
8526
+ color,
8527
+ size: 2,
8528
+ lifetime: 0.4 + system.rng.frandom() * 0.2,
8529
+ gravity: 400,
8530
+ blendMode: "additive",
8531
+ fade: true
8532
+ });
8533
+ }
8534
+ }
8535
+ function spawnBfgExplosion(context) {
8536
+ const { system, origin } = context;
8537
+ system.spawn({
8538
+ position: origin,
8539
+ velocity: { x: 0, y: 0, z: 0 },
8540
+ color: [0.2, 1, 0.2, 1],
8541
+ // Green
8542
+ size: 30,
8543
+ lifetime: 0.5,
8544
+ blendMode: "additive",
8545
+ fade: true
8546
+ });
8547
+ for (let i = 0; i < 60; i++) {
8548
+ const theta = system.rng.frandom() * Math.PI * 2;
8549
+ const phi = Math.acos(2 * system.rng.frandom() - 1);
8550
+ const speed = 300 + system.rng.frandom() * 400;
8551
+ const dir = {
8552
+ x: Math.sin(phi) * Math.cos(theta),
8553
+ y: Math.sin(phi) * Math.sin(theta),
8554
+ z: Math.cos(phi)
8555
+ };
8556
+ system.spawn({
8557
+ position: origin,
8558
+ velocity: { x: dir.x * speed, y: dir.y * speed, z: dir.z * speed },
8559
+ color: [0.2, 1, 0.2, 0.8],
8560
+ size: 4,
8561
+ lifetime: 1,
8562
+ gravity: 100,
8563
+ // Low gravity
8564
+ damping: 1,
8565
+ blendMode: "additive",
8566
+ fade: true
8567
+ });
8568
+ }
8569
+ }
8435
8570
 
8436
8571
  // src/demo/demoReader.ts
8437
8572
  var DemoReader = class {
@@ -13106,6 +13241,32 @@ var BinaryStreamAdapter = class extends StreamingBuffer {
13106
13241
  throw new Error("peekBytes not implemented for BinaryStreamAdapter");
13107
13242
  }
13108
13243
  };
13244
+ var PROTO34_MAP = {
13245
+ 0: ServerCommand.bad,
13246
+ 1: ServerCommand.nop,
13247
+ 2: ServerCommand.disconnect,
13248
+ 3: ServerCommand.reconnect,
13249
+ 4: ServerCommand.download,
13250
+ 5: ServerCommand.frame,
13251
+ 6: ServerCommand.inventory,
13252
+ 7: ServerCommand.layout,
13253
+ 8: ServerCommand.muzzleflash,
13254
+ 9: ServerCommand.sound,
13255
+ 10: ServerCommand.print,
13256
+ 11: ServerCommand.stufftext,
13257
+ 12: ServerCommand.serverdata,
13258
+ 13: ServerCommand.configstring,
13259
+ 14: ServerCommand.spawnbaseline,
13260
+ 15: ServerCommand.centerprint,
13261
+ 16: ServerCommand.download,
13262
+ 17: ServerCommand.playerinfo,
13263
+ 18: ServerCommand.packetentities,
13264
+ 19: ServerCommand.deltapacketentities,
13265
+ 23: ServerCommand.temp_entity,
13266
+ // Wire 23 -> Enum 3 (TempEntity)
13267
+ 22: ServerCommand.muzzleflash2
13268
+ // Wire 22 -> Enum 2 (MuzzleFlash2)
13269
+ };
13109
13270
  var NetworkMessageParser = class _NetworkMessageParser {
13110
13271
  constructor(stream, handler, strictMode = false) {
13111
13272
  this.protocolVersion = 0;
@@ -13147,7 +13308,9 @@ var NetworkMessageParser = class _NetworkMessageParser {
13147
13308
  return ServerCommand.bad;
13148
13309
  }
13149
13310
  if (this.protocolVersion === 34) {
13150
- if (cmd <= ServerCommand.frame) return cmd;
13311
+ if (PROTO34_MAP[cmd] !== void 0) {
13312
+ return PROTO34_MAP[cmd];
13313
+ }
13151
13314
  return ServerCommand.bad;
13152
13315
  }
13153
13316
  return cmd;
@@ -13685,7 +13848,7 @@ var NetworkMessageParser = class _NetworkMessageParser {
13685
13848
  const playerState = this.parsePlayerState();
13686
13849
  let peCmd = this.stream.readByte();
13687
13850
  peCmd = this.translateCommand(peCmd);
13688
- if (peCmd !== ServerCommand.packetentities) {
13851
+ if (peCmd !== ServerCommand.packetentities && peCmd !== ServerCommand.deltapacketentities) {
13689
13852
  if (this.strictMode) throw new Error(`Expected svc_packetentities after svc_playerinfo, got ${peCmd}`);
13690
13853
  return;
13691
13854
  }
@@ -14908,6 +15071,47 @@ var DemoValidator = class {
14908
15071
  };
14909
15072
 
14910
15073
  // src/demo/writer.ts
15074
+ var PROTO34_REVERSE_MAP = {
15075
+ [ServerCommand.bad]: 0,
15076
+ [ServerCommand.nop]: 1,
15077
+ [ServerCommand.disconnect]: 2,
15078
+ [ServerCommand.reconnect]: 3,
15079
+ // 4 is download? standard Q2 uses 4 for download sometimes, but let's stick to parser map (download=16).
15080
+ // Let's map download to 16.
15081
+ [ServerCommand.download]: 16,
15082
+ [ServerCommand.frame]: 5,
15083
+ [ServerCommand.inventory]: 6,
15084
+ [ServerCommand.layout]: 7,
15085
+ [ServerCommand.muzzleflash]: 8,
15086
+ [ServerCommand.sound]: 9,
15087
+ [ServerCommand.print]: 10,
15088
+ [ServerCommand.stufftext]: 11,
15089
+ [ServerCommand.serverdata]: 12,
15090
+ [ServerCommand.configstring]: 13,
15091
+ [ServerCommand.spawnbaseline]: 14,
15092
+ [ServerCommand.centerprint]: 15,
15093
+ // 16 is download
15094
+ [ServerCommand.playerinfo]: 17,
15095
+ [ServerCommand.packetentities]: 18,
15096
+ [ServerCommand.deltapacketentities]: 19,
15097
+ // Temp entity? Standard Q2 uses 9 for temp_entity?
15098
+ // But we mapped 9 to sound.
15099
+ // If we map temp_entity to 23 (arbitrary safe slot for internal tests) or assume standard Q2 layout:
15100
+ // Q2: svc_temp_entity = 9. svc_sound = 10.
15101
+ // My previous edit to parser.ts used 9->Sound, 10->Print.
15102
+ // I should check what I committed to `parser.ts` just now.
15103
+ // I committed: 9: Sound, 10: Print.
15104
+ // So Writer MUST MATCH Parser.
15105
+ // So if Parser says 9 is Sound, Writer must write Sound as 9.
15106
+ // But what about TempEntity?
15107
+ // Parser does NOT map any wire code to TempEntity in my recent edit (I commented out 23).
15108
+ // So TempEntity is currently broken for Protocol 34 unless I map it.
15109
+ // I will map TempEntity to 23 in both.
15110
+ [ServerCommand.temp_entity]: 23,
15111
+ // MuzzleFlash2?
15112
+ // I'll map it to 22 (arbitrary) just to have a value, or skip if unused.
15113
+ [ServerCommand.muzzleflash2]: 22
15114
+ };
14911
15115
  var MessageWriter = class {
14912
15116
  constructor() {
14913
15117
  this.writer = new BinaryWriter();
@@ -14915,9 +15119,18 @@ var MessageWriter = class {
14915
15119
  getData() {
14916
15120
  return this.writer.getData();
14917
15121
  }
14918
- // ... (unchanged methods)
15122
+ writeCommand(cmd, protocolVersion = 0) {
15123
+ if (protocolVersion === 34) {
15124
+ const translated = PROTO34_REVERSE_MAP[cmd];
15125
+ if (translated !== void 0) {
15126
+ this.writer.writeByte(translated);
15127
+ return;
15128
+ }
15129
+ }
15130
+ this.writer.writeByte(cmd);
15131
+ }
14919
15132
  writeServerData(protocol, serverCount, attractLoop, gameDir, playerNum, levelName) {
14920
- this.writer.writeByte(ServerCommand.serverdata);
15133
+ this.writeCommand(ServerCommand.serverdata, protocol);
14921
15134
  this.writer.writeLong(protocol);
14922
15135
  this.writer.writeLong(serverCount);
14923
15136
  this.writer.writeByte(attractLoop);
@@ -14926,7 +15139,7 @@ var MessageWriter = class {
14926
15139
  this.writer.writeString(levelName);
14927
15140
  }
14928
15141
  writeServerDataRerelease(protocol, spawnCount, demoType, tickRate, gameDir, playerNum, levelName) {
14929
- this.writer.writeByte(ServerCommand.serverdata);
15142
+ this.writeCommand(ServerCommand.serverdata, protocol);
14930
15143
  this.writer.writeLong(protocol);
14931
15144
  this.writer.writeLong(spawnCount);
14932
15145
  this.writer.writeByte(demoType);
@@ -14935,53 +15148,178 @@ var MessageWriter = class {
14935
15148
  this.writer.writeShort(playerNum);
14936
15149
  this.writer.writeString(levelName);
14937
15150
  }
14938
- writeConfigString(index, str) {
14939
- this.writer.writeByte(ServerCommand.configstring);
15151
+ writeConfigString(index, str, protocolVersion = 0) {
15152
+ this.writeCommand(ServerCommand.configstring, protocolVersion);
14940
15153
  this.writer.writeShort(index);
14941
15154
  this.writer.writeString(str);
14942
15155
  }
14943
15156
  writeSpawnBaseline(entity, protocolVersion) {
14944
- this.writer.writeByte(ServerCommand.spawnbaseline);
15157
+ this.writeCommand(ServerCommand.spawnbaseline, protocolVersion);
14945
15158
  this.writeEntityState(entity, null, true, protocolVersion);
14946
15159
  }
14947
- writeStuffText(text) {
14948
- this.writer.writeByte(ServerCommand.stufftext);
15160
+ writeStuffText(text, protocolVersion = 0) {
15161
+ this.writeCommand(ServerCommand.stufftext, protocolVersion);
14949
15162
  this.writer.writeString(text);
14950
15163
  }
14951
- writeCenterPrint(text) {
14952
- this.writer.writeByte(ServerCommand.centerprint);
15164
+ writeCenterPrint(text, protocolVersion = 0) {
15165
+ this.writeCommand(ServerCommand.centerprint, protocolVersion);
14953
15166
  this.writer.writeString(text);
14954
15167
  }
14955
- writePrint(level, text) {
14956
- this.writer.writeByte(ServerCommand.print);
15168
+ writePrint(level, text, protocolVersion = 0) {
15169
+ this.writeCommand(ServerCommand.print, protocolVersion);
14957
15170
  this.writer.writeByte(level);
14958
15171
  this.writer.writeString(text);
14959
15172
  }
14960
- writeLayout(layout) {
14961
- this.writer.writeByte(ServerCommand.layout);
15173
+ writeLayout(layout, protocolVersion = 0) {
15174
+ this.writeCommand(ServerCommand.layout, protocolVersion);
14962
15175
  this.writer.writeString(layout);
14963
15176
  }
14964
- writeInventory(inventory) {
14965
- this.writer.writeByte(ServerCommand.inventory);
15177
+ writeInventory(inventory, protocolVersion = 0) {
15178
+ this.writeCommand(ServerCommand.inventory, protocolVersion);
14966
15179
  for (let i = 0; i < 256; i++) {
14967
15180
  this.writer.writeShort(inventory[i] || 0);
14968
15181
  }
14969
15182
  }
14970
- writeMuzzleFlash(ent, weapon) {
14971
- this.writer.writeByte(ServerCommand.muzzleflash);
15183
+ writeMuzzleFlash(ent, weapon, protocolVersion = 0) {
15184
+ this.writeCommand(ServerCommand.muzzleflash, protocolVersion);
14972
15185
  this.writer.writeShort(ent);
14973
15186
  this.writer.writeByte(weapon);
14974
15187
  }
14975
- writeMuzzleFlash2(ent, weapon) {
14976
- this.writer.writeByte(ServerCommand.muzzleflash2);
15188
+ writeMuzzleFlash2(ent, weapon, protocolVersion = 0) {
15189
+ this.writeCommand(ServerCommand.muzzleflash2, protocolVersion);
14977
15190
  this.writer.writeShort(ent);
14978
15191
  this.writer.writeByte(weapon);
14979
15192
  }
14980
- writeTempEntity(type, pos, pos2, dir, cnt, color, ent, srcEnt, destEnt) {
14981
- console.warn("writeTempEntity not implemented - skipping message");
15193
+ writeTempEntity(type, pos, pos2, dir, cnt, color, ent, srcEnt, destEnt, protocolVersion = 0) {
15194
+ this.writeCommand(ServerCommand.temp_entity, protocolVersion);
15195
+ this.writer.writeByte(type);
15196
+ switch (type) {
15197
+ case TempEntity.EXPLOSION1:
15198
+ case TempEntity.EXPLOSION2:
15199
+ case TempEntity.ROCKET_EXPLOSION:
15200
+ case TempEntity.GRENADE_EXPLOSION:
15201
+ case TempEntity.ROCKET_EXPLOSION_WATER:
15202
+ case TempEntity.GRENADE_EXPLOSION_WATER:
15203
+ case TempEntity.BFG_EXPLOSION:
15204
+ case TempEntity.BFG_BIGEXPLOSION:
15205
+ case TempEntity.BOSSTPORT:
15206
+ case TempEntity.PLASMA_EXPLOSION:
15207
+ case TempEntity.PLAIN_EXPLOSION:
15208
+ case TempEntity.CHAINFIST_SMOKE:
15209
+ case TempEntity.TRACKER_EXPLOSION:
15210
+ case TempEntity.TELEPORT_EFFECT:
15211
+ case TempEntity.DBALL_GOAL:
15212
+ case TempEntity.NUKEBLAST:
15213
+ case TempEntity.WIDOWSPLASH:
15214
+ case TempEntity.EXPLOSION1_BIG:
15215
+ case TempEntity.EXPLOSION1_NP:
15216
+ this.writer.writePos(pos);
15217
+ break;
15218
+ case TempEntity.GUNSHOT:
15219
+ case TempEntity.BLOOD:
15220
+ case TempEntity.BLASTER:
15221
+ case TempEntity.SHOTGUN:
15222
+ case TempEntity.SPARKS:
15223
+ case TempEntity.BULLET_SPARKS:
15224
+ case TempEntity.SCREEN_SPARKS:
15225
+ case TempEntity.SHIELD_SPARKS:
15226
+ case TempEntity.BLASTER2:
15227
+ case TempEntity.FLECHETTE:
15228
+ case TempEntity.MOREBLOOD:
15229
+ case TempEntity.ELECTRIC_SPARKS:
15230
+ case TempEntity.HEATBEAM_SPARKS:
15231
+ case TempEntity.HEATBEAM_STEAM:
15232
+ this.writer.writePos(pos);
15233
+ this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
15234
+ break;
15235
+ case TempEntity.SPLASH:
15236
+ case TempEntity.LASER_SPARKS:
15237
+ case TempEntity.WELDING_SPARKS:
15238
+ case TempEntity.TUNNEL_SPARKS:
15239
+ this.writer.writeByte(cnt || 0);
15240
+ this.writer.writePos(pos);
15241
+ this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
15242
+ this.writer.writeByte(color || 0);
15243
+ break;
15244
+ case TempEntity.BLUEHYPERBLASTER:
15245
+ if (protocolVersion >= 32) {
15246
+ this.writer.writePos(pos);
15247
+ this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15248
+ } else {
15249
+ this.writer.writePos(pos);
15250
+ this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
15251
+ }
15252
+ break;
15253
+ case TempEntity.GREENBLOOD:
15254
+ if (protocolVersion >= 32) {
15255
+ this.writer.writePos(pos);
15256
+ this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
15257
+ } else {
15258
+ this.writer.writePos(pos);
15259
+ this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15260
+ }
15261
+ break;
15262
+ case TempEntity.RAILTRAIL:
15263
+ case TempEntity.BUBBLETRAIL:
15264
+ case TempEntity.BFG_LASER:
15265
+ case TempEntity.DEBUGTRAIL:
15266
+ case TempEntity.BUBBLETRAIL2:
15267
+ this.writer.writePos(pos);
15268
+ this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15269
+ break;
15270
+ case TempEntity.PARASITE_ATTACK:
15271
+ case TempEntity.MEDIC_CABLE_ATTACK:
15272
+ this.writer.writeShort(ent || 0);
15273
+ this.writer.writePos(pos);
15274
+ this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15275
+ break;
15276
+ case TempEntity.GRAPPLE_CABLE:
15277
+ this.writer.writeShort(ent || 0);
15278
+ this.writer.writePos(pos);
15279
+ this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15280
+ this.writer.writePos(dir || { x: 0, y: 0, z: 0 });
15281
+ break;
15282
+ case TempEntity.LIGHTNING:
15283
+ this.writer.writeShort(srcEnt || 0);
15284
+ this.writer.writeShort(destEnt || 0);
15285
+ this.writer.writePos(pos);
15286
+ this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15287
+ break;
15288
+ case TempEntity.FLASHLIGHT:
15289
+ this.writer.writePos(pos);
15290
+ this.writer.writeShort(ent || 0);
15291
+ break;
15292
+ case TempEntity.FORCEWALL:
15293
+ this.writer.writePos(pos);
15294
+ this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15295
+ this.writer.writeByte(color || 0);
15296
+ break;
15297
+ case TempEntity.STEAM:
15298
+ this.writer.writeShort(-1);
15299
+ this.writer.writeByte(cnt || 0);
15300
+ this.writer.writePos(pos);
15301
+ this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
15302
+ this.writer.writeByte(color || 0);
15303
+ this.writer.writeShort(0);
15304
+ break;
15305
+ case TempEntity.WIDOWBEAMOUT:
15306
+ this.writer.writeShort(0);
15307
+ // ent
15308
+ // Fallthrough
15309
+ case TempEntity.HEATBEAM:
15310
+ case TempEntity.MONSTER_HEATBEAM:
15311
+ this.writer.writeShort(ent || 0);
15312
+ this.writer.writePos(pos);
15313
+ this.writer.writePos(pos2 || { x: 0, y: 0, z: 0 });
15314
+ this.writer.writeDir(dir || { x: 0, y: 0, z: 0 });
15315
+ break;
15316
+ default:
15317
+ console.warn(`writeTempEntity: Unhandled type ${type}`);
15318
+ break;
15319
+ }
14982
15320
  }
14983
- writeSound(mask, soundNum, volume, attenuation, offset, ent, pos) {
14984
- this.writer.writeByte(ServerCommand.sound);
15321
+ writeSound(mask, soundNum, volume, attenuation, offset, ent, pos, protocolVersion = 0) {
15322
+ this.writeCommand(ServerCommand.sound, protocolVersion);
14985
15323
  this.writer.writeByte(mask);
14986
15324
  this.writer.writeByte(soundNum);
14987
15325
  if (mask & 1) this.writer.writeByte(volume || 0);
@@ -14994,14 +15332,14 @@ var MessageWriter = class {
14994
15332
  this.writer.writeCoord(pos.z);
14995
15333
  }
14996
15334
  }
14997
- writeDisconnect() {
14998
- this.writer.writeByte(ServerCommand.disconnect);
15335
+ writeDisconnect(protocolVersion = 0) {
15336
+ this.writeCommand(ServerCommand.disconnect, protocolVersion);
14999
15337
  }
15000
- writeReconnect() {
15001
- this.writer.writeByte(ServerCommand.reconnect);
15338
+ writeReconnect(protocolVersion = 0) {
15339
+ this.writeCommand(ServerCommand.reconnect, protocolVersion);
15002
15340
  }
15003
15341
  writeFrame(frame, protocolVersion) {
15004
- this.writer.writeByte(ServerCommand.frame);
15342
+ this.writeCommand(ServerCommand.frame, protocolVersion);
15005
15343
  this.writer.writeLong(frame.serverFrame);
15006
15344
  this.writer.writeLong(frame.deltaFrame);
15007
15345
  if (protocolVersion !== 25 && protocolVersion !== 26) {
@@ -15011,7 +15349,7 @@ var MessageWriter = class {
15011
15349
  if (frame.areaBytes > 0) {
15012
15350
  this.writer.writeBytes(frame.areaBits);
15013
15351
  }
15014
- this.writer.writeByte(ServerCommand.playerinfo);
15352
+ this.writeCommand(ServerCommand.playerinfo, protocolVersion);
15015
15353
  this.writePlayerState(frame.playerState);
15016
15354
  this.writePacketEntities(frame.packetEntities.entities, frame.packetEntities.delta, protocolVersion);
15017
15355
  }
@@ -15095,7 +15433,7 @@ var MessageWriter = class {
15095
15433
  }
15096
15434
  }
15097
15435
  writePacketEntities(entities, delta, protocolVersion) {
15098
- this.writer.writeByte(delta ? ServerCommand.deltapacketentities : ServerCommand.packetentities);
15436
+ this.writeCommand(delta ? ServerCommand.deltapacketentities : ServerCommand.packetentities, protocolVersion);
15099
15437
  for (const ent of entities) {
15100
15438
  const force = !delta;
15101
15439
  this.writeEntityState(ent, null, force, protocolVersion);
@@ -15412,7 +15750,7 @@ var DemoClipper = class {
15412
15750
  );
15413
15751
  }
15414
15752
  for (const [index, str] of worldState.configStrings) {
15415
- headerWriter.writeConfigString(index, str);
15753
+ headerWriter.writeConfigString(index, str, serverData.protocol);
15416
15754
  }
15417
15755
  for (const entity of worldState.entityBaselines.values()) {
15418
15756
  headerWriter.writeSpawnBaseline(entity, serverData.protocol);
@@ -15447,19 +15785,19 @@ var DemoClipper = class {
15447
15785
  const passthroughHandler = {
15448
15786
  onServerData: () => {
15449
15787
  },
15450
- onConfigString: (idx, str) => blockWriter.writeConfigString(idx, str),
15788
+ onConfigString: (idx, str) => blockWriter.writeConfigString(idx, str, serverData.protocol),
15451
15789
  onSpawnBaseline: (ent) => blockWriter.writeSpawnBaseline(ent, serverData.protocol),
15452
- onCenterPrint: (msg) => blockWriter.writeCenterPrint(msg),
15453
- onStuffText: (txt) => blockWriter.writeStuffText(txt),
15454
- onPrint: (lvl, msg) => blockWriter.writePrint(lvl, msg),
15455
- onSound: (mask, s, v, a, o, e, p) => blockWriter.writeSound(mask, s, v, a, o, e, p),
15456
- onLayout: (l) => blockWriter.writeLayout(l),
15457
- onInventory: (inv) => blockWriter.writeInventory(inv),
15458
- onMuzzleFlash: (ent, w) => blockWriter.writeMuzzleFlash(ent, w),
15459
- onMuzzleFlash2: (ent, w) => blockWriter.writeMuzzleFlash2(ent, w),
15460
- onTempEntity: (t, p, p2, d, c, clr, e, s, de) => blockWriter.writeTempEntity(t, p, p2, d, c, clr, e, s, de),
15461
- onDisconnect: () => blockWriter.writeDisconnect(),
15462
- onReconnect: () => blockWriter.writeReconnect(),
15790
+ onCenterPrint: (msg) => blockWriter.writeCenterPrint(msg, serverData.protocol),
15791
+ onStuffText: (txt) => blockWriter.writeStuffText(txt, serverData.protocol),
15792
+ onPrint: (lvl, msg) => blockWriter.writePrint(lvl, msg, serverData.protocol),
15793
+ onSound: (mask, s, v, a, o, e, p) => blockWriter.writeSound(mask, s, v, a, o, e, p, serverData.protocol),
15794
+ onLayout: (l) => blockWriter.writeLayout(l, serverData.protocol),
15795
+ onInventory: (inv) => blockWriter.writeInventory(inv, serverData.protocol),
15796
+ onMuzzleFlash: (ent, w) => blockWriter.writeMuzzleFlash(ent, w, serverData.protocol),
15797
+ onMuzzleFlash2: (ent, w) => blockWriter.writeMuzzleFlash2(ent, w, serverData.protocol),
15798
+ onTempEntity: (t, p, p2, d, c, clr, e, s, de) => blockWriter.writeTempEntity(t, p, p2, d, c, clr, e, s, de, serverData.protocol),
15799
+ onDisconnect: () => blockWriter.writeDisconnect(serverData.protocol),
15800
+ onReconnect: () => blockWriter.writeReconnect(serverData.protocol),
15463
15801
  onDownload: () => {
15464
15802
  },
15465
15803
  // Stub for download
@@ -16142,10 +16480,14 @@ function createEngine(imports) {
16142
16480
  removeViewTranslation,
16143
16481
  resolveLightStyles,
16144
16482
  serializeEntLump,
16483
+ spawnBfgExplosion,
16484
+ spawnBlasterImpact,
16145
16485
  spawnBlood,
16146
16486
  spawnBulletImpact,
16147
16487
  spawnExplosion,
16148
16488
  spawnMuzzleFlash,
16489
+ spawnRailTrail,
16490
+ spawnSparks,
16149
16491
  spawnSplash,
16150
16492
  spawnSteam,
16151
16493
  spawnTeleportFlash,