Skip to content

Runtime IMG container#4757

Open
Xenius97 wants to merge 1 commit into
multitheftauto:masterfrom
Xenius97:new/runtime_image
Open

Runtime IMG container#4757
Xenius97 wants to merge 1 commit into
multitheftauto:masterfrom
Xenius97:new/runtime_image

Conversation

@Xenius97
Copy link
Copy Markdown
Contributor

Summary

This PR adds runtime image containers through engineLoadIMG folder support.

When engineLoadIMG receives a folder path, the client builds a temporary IMG archive in the resource root directory, then streams models from that generated IMG the same way as a normal archive. This lets resources update individual files instead of forcing players to redownload one large static IMG every time. Runtime archives are created in the resource root with names like runtime-image-<tick>-<pid>.tmp and deleted automatically when resource stops (also cleared when it starts, so if your game crashes for some reason at next time this will do a cleanup)

Motivation

Updating model containers is currently expensive for players.
If one file changes inside a large IMG, clients must download the whole archive again.

With this change, resources can ship model files individually, and the client assembles a runtime IMG locally. This reduces client-side update overhead and saves server bandwidth, because players no longer need to redownload hundreds of MB when only a few files change.

Test plan

Resource:
runtime_img.zip

Everything works same as normal img containers.
image

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

@Xenius97 Xenius97 requested a review from a team as a code owner March 13, 2026 10:54
@Xenius97 Xenius97 mentioned this pull request Mar 13, 2026
1 task
@FileEX FileEX added the enhancement New feature or request label Apr 8, 2026
@lynconsl
Copy link
Copy Markdown

lynconsl commented May 9, 2026

Hi, any news about PR? I'm just waiting

@Xenius97
Copy link
Copy Markdown
Contributor Author

Nobody check it, so just wait. Would be cool with 1.7

@qaisjp
Copy link
Copy Markdown
Member

qaisjp commented May 10, 2026

What is the point of img in the first place?

@lynconsl
Copy link
Copy Markdown

What is the point of img in the first place?

To allow some users to employ .img files without having to use multiple .txd/.dff (.col) files, .img organizes the files in a compact and systematic manner

@qaisjp
Copy link
Copy Markdown
Member

qaisjp commented May 10, 2026

Found it -- saves client memory and optimises load time according to: #1677

@qaisjp
Copy link
Copy Markdown
Member

qaisjp commented May 10, 2026

This is a cool idea but I wonder if it'd make sense to instead support some sort of "file patching" system for large files (like bsdiff / bspatch).

This would move the optimisation into file downloading, which could work for all types of large files, rather than changing how the img is loaded client side.

@qaisjp qaisjp force-pushed the new/runtime_image branch from f06ef34 to 6033402 Compare May 10, 2026 17:26
@Xenius97
Copy link
Copy Markdown
Contributor Author

Actually, this only creates a temporary IMG archive that SA can load afterward. The files themselves are still downloaded individually, just like in every other case. The end result is that if you modify something, you don’t have to re-download a 600–800 MB archive again, only the single modified file. This also reduces the load on the HTTP server when multiple players are downloading at the same time.

I couldn’t find any other solution, and based on my tests, this was the only viable approach that actually worked.
I didn’t change anything about the original loading process, the only difference is that when it receives a folder path, it creates a temporary archive, mounts it, and uses that instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants