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.
@@ -3923,6 +3923,23 @@ function createCGameImport(imports, state) {
3923
3923
  CL_GetKeyBinding: (key) => {
3924
3924
  return state.getKeyBinding(key);
3925
3925
  },
3926
+ // Asset Registration
3927
+ RegisterModel: (name) => {
3928
+ if (!imports.engine.assets) return;
3929
+ const ext = name.split(".").pop()?.toLowerCase();
3930
+ if (ext === "md2") {
3931
+ imports.engine.assets.loadMd2Model(name).catch((e) => console.warn(`Failed to precache MD2 ${name}`, e));
3932
+ } else if (ext === "sp2") {
3933
+ imports.engine.assets.loadSprite(name).catch((e) => console.warn(`Failed to precache Sprite ${name}`, e));
3934
+ } else if (ext === "md3") {
3935
+ imports.engine.assets.loadMd3Model(name).catch((e) => console.warn(`Failed to precache MD3 ${name}`, e));
3936
+ }
3937
+ },
3938
+ RegisterSound: (name) => {
3939
+ if (imports.engine.assets) {
3940
+ imports.engine.assets.loadSound(name).catch((e) => console.warn(`Failed to precache sound ${name}`, e));
3941
+ }
3942
+ },
3926
3943
  // Drawing
3927
3944
  Draw_RegisterPic: (name) => {
3928
3945
  if (picCache.has(name)) {
@@ -6690,27 +6707,7 @@ function createClient(imports) {
6690
6707
  },
6691
6708
  ParseConfigString(index, value) {
6692
6709
  configStrings.set(index, value);
6693
- if (imports.engine.assets) {
6694
- const assets = imports.engine.assets;
6695
- if (index >= ConfigStringIndex2.Models && index < ConfigStringIndex2.Models + MAX_MODELS2) {
6696
- const ext = value.split(".").pop()?.toLowerCase();
6697
- if (ext === "md2") {
6698
- assets.loadMd2Model(value).catch((e) => console.warn(`Failed to precache MD2 ${value}`, e));
6699
- } else if (ext === "sp2") {
6700
- assets.loadSprite(value).catch((e) => console.warn(`Failed to precache Sprite ${value}`, e));
6701
- } else if (ext === "md3") {
6702
- assets.loadMd3Model(value).catch((e) => console.warn(`Failed to precache MD3 ${value}`, e));
6703
- }
6704
- } else if (index >= ConfigStringIndex2.Sounds && index < ConfigStringIndex2.Sounds + MAX_SOUNDS2) {
6705
- assets.loadSound(value).catch((e) => console.warn(`Failed to precache sound ${value}`, e));
6706
- } else if (index >= ConfigStringIndex2.Images && index < ConfigStringIndex2.Images + MAX_IMAGES2) {
6707
- assets.loadTexture(value).then((texture) => {
6708
- if (imports.engine.renderer) {
6709
- imports.engine.renderer.registerTexture(value, texture);
6710
- }
6711
- }).catch((e) => console.warn(`Failed to precache image ${value}`, e));
6712
- }
6713
- }
6710
+ cg.ParseConfigString(index, value);
6714
6711
  },
6715
6712
  demoHandler,
6716
6713
  configStrings