quake2ts 0.0.197 → 0.0.198

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.
@@ -3809,9 +3809,121 @@ var AmmoType2 = /* @__PURE__ */ ((AmmoType22) => {
3809
3809
  var AMMO_TYPE_COUNT2 = Object.keys(AmmoType2).length / 2;
3810
3810
 
3811
3811
  // src/index.ts
3812
- import { ClientPrediction, interpolatePredictionState as interpolatePredictionState2 } from "@quake2ts/cgame";
3812
+ import { ClientPrediction, interpolatePredictionState as interpolatePredictionState2, GetCGameAPI } from "@quake2ts/cgame";
3813
3813
  import { ViewEffects } from "@quake2ts/cgame";
3814
3814
 
3815
+ // src/cgameBridge.ts
3816
+ function createCGameImport(imports) {
3817
+ const getRenderer = () => imports.engine.renderer;
3818
+ return {
3819
+ // Frame timing - stubbed for now until we fix the access pattern
3820
+ get tick_rate() {
3821
+ return 10;
3822
+ },
3823
+ get frame_time_s() {
3824
+ return 0;
3825
+ },
3826
+ get frame_time_ms() {
3827
+ return 0;
3828
+ },
3829
+ // Console
3830
+ Com_Print: (msg) => {
3831
+ console.log(`[CGAME] ${msg}`);
3832
+ },
3833
+ Com_Error: (msg) => {
3834
+ console.error(`[CGAME ERROR] ${msg}`);
3835
+ },
3836
+ // Config strings
3837
+ get_configstring: (num) => {
3838
+ return "";
3839
+ },
3840
+ // Memory (No-op in JS)
3841
+ TagMalloc: (size, tag) => ({}),
3842
+ TagFree: (ptr) => {
3843
+ },
3844
+ FreeTags: (tag) => {
3845
+ },
3846
+ // Cvars
3847
+ cvar: (name, value, flags) => {
3848
+ return null;
3849
+ },
3850
+ cvar_set: (name, value) => {
3851
+ if (imports.host?.cvars) {
3852
+ imports.host.cvars.setValue(name, value);
3853
+ }
3854
+ },
3855
+ cvar_forceset: (name, value) => {
3856
+ if (imports.host?.cvars) {
3857
+ imports.host.cvars.setValue(name, value);
3858
+ }
3859
+ },
3860
+ // Client state
3861
+ CL_FrameValid: () => true,
3862
+ CL_FrameTime: () => 0,
3863
+ CL_ClientTime: () => 0,
3864
+ CL_ServerFrame: () => 0,
3865
+ CL_ServerProtocol: () => 34,
3866
+ // Client info
3867
+ CL_GetClientName: (playerNum) => {
3868
+ return `Player ${playerNum}`;
3869
+ },
3870
+ CL_GetClientPic: (playerNum) => {
3871
+ return "";
3872
+ },
3873
+ CL_GetClientDogtag: (playerNum) => {
3874
+ return "";
3875
+ },
3876
+ CL_GetKeyBinding: (key) => {
3877
+ return `[${key}]`;
3878
+ },
3879
+ // Drawing
3880
+ Draw_RegisterPic: (name) => {
3881
+ if (imports.engine.assets) {
3882
+ return name;
3883
+ }
3884
+ return name;
3885
+ },
3886
+ Draw_GetPicSize: (pic) => {
3887
+ return { width: 32, height: 32 };
3888
+ },
3889
+ SCR_DrawChar: (x, y, char) => {
3890
+ getRenderer()?.drawString(x, y, String.fromCharCode(char));
3891
+ },
3892
+ SCR_DrawPic: (x, y, pic) => {
3893
+ const name = pic;
3894
+ },
3895
+ SCR_DrawColorPic: (x, y, pic, color, alpha) => {
3896
+ },
3897
+ SCR_DrawFontString: (x, y, str3) => {
3898
+ getRenderer()?.drawString(x, y, str3);
3899
+ },
3900
+ SCR_DrawCenterString: (y, str3) => {
3901
+ getRenderer()?.drawCenterString(y, str3);
3902
+ },
3903
+ SCR_MeasureFontString: (str3) => {
3904
+ const stripped = str3.replace(/\^[0-9]/g, "");
3905
+ return stripped.length * 8;
3906
+ },
3907
+ SCR_FontLineHeight: () => 8,
3908
+ SCR_SetAltTypeface: (alt) => {
3909
+ },
3910
+ SCR_DrawBind: (x, y, command) => {
3911
+ getRenderer()?.drawString(x, y, `[${command}]`);
3912
+ },
3913
+ // Localization
3914
+ Localize: (key) => key,
3915
+ // State queries
3916
+ CL_GetTextInput: () => "",
3917
+ CL_GetWarnAmmoCount: () => 5,
3918
+ // Low ammo threshold
3919
+ CL_InAutoDemoLoop: () => false,
3920
+ // Prediction Trace
3921
+ PM_Trace: (start, end, mins, maxs) => {
3922
+ return imports.engine.trace(start, end);
3923
+ }
3924
+ };
3925
+ }
3926
+
3815
3927
  // src/hud/crosshair.ts
3816
3928
  var crosshairPic = null;
3817
3929
  var crosshairIndex = 0;
@@ -6126,6 +6238,8 @@ function createClient(imports) {
6126
6238
  let lastRendered;
6127
6239
  let lastView;
6128
6240
  let camera;
6241
+ const cgameImport = createCGameImport(imports);
6242
+ const cg = GetCGameAPI(cgameImport);
6129
6243
  let fovValue = 90;
6130
6244
  let isZooming = false;
6131
6245
  if (imports.host) {
@@ -6202,6 +6316,7 @@ function createClient(imports) {
6202
6316
  if (initial?.state) {
6203
6317
  prediction.setAuthoritative(initial);
6204
6318
  }
6319
+ cg.Init();
6205
6320
  if (imports.engine.assets && imports.engine.renderer) {
6206
6321
  loadingScreen.start(100, "Loading assets...");
6207
6322
  Init_Hud(imports.engine.renderer, imports.engine.assets).then(() => {
@@ -6431,6 +6546,7 @@ function createClient(imports) {
6431
6546
  this.Shutdown();
6432
6547
  },
6433
6548
  Shutdown() {
6549
+ cg.Shutdown();
6434
6550
  latestFrame = void 0;
6435
6551
  lastRendered = void 0;
6436
6552
  if (imports.host?.cvars) {