quake2ts 0.0.204 → 0.0.205

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.
@@ -3892,6 +3892,23 @@ function createCGameImport(imports, state) {
3892
3892
  CL_GetKeyBinding: (key) => {
3893
3893
  return state.getKeyBinding(key);
3894
3894
  },
3895
+ // Asset Registration
3896
+ RegisterModel: (name) => {
3897
+ if (!imports.engine.assets) return;
3898
+ const ext = name.split(".").pop()?.toLowerCase();
3899
+ if (ext === "md2") {
3900
+ imports.engine.assets.loadMd2Model(name).catch((e) => console.warn(`Failed to precache MD2 ${name}`, e));
3901
+ } else if (ext === "sp2") {
3902
+ imports.engine.assets.loadSprite(name).catch((e) => console.warn(`Failed to precache Sprite ${name}`, e));
3903
+ } else if (ext === "md3") {
3904
+ imports.engine.assets.loadMd3Model(name).catch((e) => console.warn(`Failed to precache MD3 ${name}`, e));
3905
+ }
3906
+ },
3907
+ RegisterSound: (name) => {
3908
+ if (imports.engine.assets) {
3909
+ imports.engine.assets.loadSound(name).catch((e) => console.warn(`Failed to precache sound ${name}`, e));
3910
+ }
3911
+ },
3895
3912
  // Drawing
3896
3913
  Draw_RegisterPic: (name) => {
3897
3914
  if (picCache.has(name)) {
@@ -6662,27 +6679,7 @@ function createClient(imports) {
6662
6679
  },
6663
6680
  ParseConfigString(index, value) {
6664
6681
  configStrings.set(index, value);
6665
- if (imports.engine.assets) {
6666
- const assets = imports.engine.assets;
6667
- if (index >= ConfigStringIndex2.Models && index < ConfigStringIndex2.Models + MAX_MODELS2) {
6668
- const ext = value.split(".").pop()?.toLowerCase();
6669
- if (ext === "md2") {
6670
- assets.loadMd2Model(value).catch((e) => console.warn(`Failed to precache MD2 ${value}`, e));
6671
- } else if (ext === "sp2") {
6672
- assets.loadSprite(value).catch((e) => console.warn(`Failed to precache Sprite ${value}`, e));
6673
- } else if (ext === "md3") {
6674
- assets.loadMd3Model(value).catch((e) => console.warn(`Failed to precache MD3 ${value}`, e));
6675
- }
6676
- } else if (index >= ConfigStringIndex2.Sounds && index < ConfigStringIndex2.Sounds + MAX_SOUNDS2) {
6677
- assets.loadSound(value).catch((e) => console.warn(`Failed to precache sound ${value}`, e));
6678
- } else if (index >= ConfigStringIndex2.Images && index < ConfigStringIndex2.Images + MAX_IMAGES2) {
6679
- assets.loadTexture(value).then((texture) => {
6680
- if (imports.engine.renderer) {
6681
- imports.engine.renderer.registerTexture(value, texture);
6682
- }
6683
- }).catch((e) => console.warn(`Failed to precache image ${value}`, e));
6684
- }
6685
- }
6682
+ cg.ParseConfigString(index, value);
6686
6683
  },
6687
6684
  demoHandler,
6688
6685
  configStrings