Skip to content

Download server models as compressed segments before joining - #437

Open
Rehasher wants to merge 1 commit into
openmultiplayer:masterfrom
Rehasher:model-pack
Open

Rehasher wants to merge 1 commit into
openmultiplayer:masterfrom
Rehasher:model-pack

Conversation

@Rehasher

Copy link
Copy Markdown

Goes with the model pack change in open.mp, which lets a server hand out all of its custom models as a few compressed files instead of one request per .dff/.txd.

Before the game starts with the open.mp client, the launcher asks the server's game ip and port for /modelpack/v1/index.json. If there's no index (old server, artwork.port changed, artwork.model_pack set to false on the server, or the server is still compressing its models) nothing happens and the game downloads models like it did before.

Otherwise it checks which files are missing from the model cache (name, size and CRC32 all have to match) and only downloads the segments that have them, with a progress box in the launcher window. Each file's CRC32 is checked before it goes in the cache, so a download that gets cut off or a bad file leaves nothing broken, and the game fetches whatever is still missing the usual way. If the server is busy with other downloads it waits and asks again a few times. Players who already have most of the models only get the segments that changed. There's no limit on how big the models can be.

The code is src-tauri/src/model_pack.rs, called from the inject command, plus a few lines in game.ts for the progress box.

Adds three crates: ureq (plain http only), flate2 and crc32fast.

Goes with the model pack change in open.mp, which lets a server hand out all of its custom models as a few compressed files instead of one request per .dff/.txd.

Before the game starts with the open.mp client, the launcher asks the server's game ip and port for /modelpack/v1/index.json. If there's no index (old server, artwork.port changed, artwork.model_pack set to false on the server, or the server is still compressing its models) nothing happens and the game downloads models like it did before.

Otherwise it checks which files are missing from the model cache (name, size and CRC32 all have to match) and only downloads the segments that have them, with a progress box in the launcher window. Each file's CRC32 is checked before it goes in the cache, so a download that gets cut off or a bad file leaves nothing broken, and the game fetches whatever is still missing the usual way. If the server is busy with other downloads it waits and asks again a few times. Players who already have most of the models only get the segments that changed. There's no limit on how big the models can be.

The code is src-tauri/src/model_pack.rs, called from the inject command, plus a few lines in game.ts for the progress box.

Adds three crates: ureq (plain http only), flate2 and crc32fast.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant