Client Update Protocol

Started by unknown, February 28, 2010, 08:07:25 AM

Previous topic - Next topic

unknown

Communication is done over HTTP 1.1
Client (StarCraft II.exe) sends a GET request from port 3622 to:

dist.blizzard.com.edgesuite.net/sc2patch/update/B14133B/sc2-0.3.0.14093-0.4.0.14133-x86-Win-enUS-game-component-dl

UserAgent is "Blizzard Web Client".

Apache server responds with code 200 (OK) and binary data of the file that needs to be updated.

Next, client requests the patch notes from:
www.starcraft2.com/launcher/patch-notes.htm

After the patching process has finished, client notifies the server by sending a POST request to:
us-beta.patch.battle.net:1120

with the following XML data:

<version program="S2">
  <record program="SC2" component="Win" version="14133" />
  <record program="SC2" component="enUS" version="14133" />
  <record program="Bnet" component="base" version="3832" />
  <record program="Bnet" component="Win" version="17577" />
  <record program="Tool" component="Win" version="1406" />
</version>


Server replies with code 204 (No Content) and closes the connection.

stormbreaker

Do you have information what happens if there is available patch to install?

prefix331

Isn't that what this post is about lol?

stormbreaker

Quote from: prefix331 on March 03, 2010, 02:32:17 AM
Isn't that what this post is about lol?


Lol true. I must have been very sleepy  ???

prefix331


stormbreaker

#5
Looks like this information isn't complete. Here is what I found out.


1. The client sends POST request to us-beta.patch.battle.net:1120 with the following XML data:
<version program="S2">
  <record program="SC2" component="Win" version="[...Version number...]" />
  <record program="SC2" component="enUS" version="[...Version number...]" />
  <record program="Bnet" component="base" version="[...Version number...]" />
  <record program="Bnet" component="Win" version="[...Version number...]" />
  <record program="Tool" component="Win" version="[...Version number...]" />
</version>


2. If the server detects we have the lastest version it sends 204 (No Content) as said in the first post.

If we need an update the server sends HTTP/1.1 200 OK
Server: Protocol HTTP
Content-Length: 1118
Connection: close
Content-Type: application/xml

<patch>
<record program="SC2" component="Win">
http://dist.blizzard.com.edgesuite.net/sc2patch/update/B14093B/sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-game-component-dl;sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-game-component-dl;FE4E80465692A2F9C47C2723D184E933;14093
</record>
<record program="SC2" component="enUS">
http://dist.blizzard.com.edgesuite.net/sc2patch/update/B14093B/sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-locale-component-dl;sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-locale-component-dl;49750B9F1473283D7DA44622E021833B;14093
</record>
<record program="Bnet" component="base">
http://dist.blizzard.com.edgesuite.net/sc2patch/update/B14093B/sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-bnet-base-component-dl;sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-bnet-base-component-dl;68CC1B35027ECE4B1D1704666344A29E;14093
</record>
<record program="Bnet" component="Win">
http://dist.blizzard.com.edgesuite.net/sc2patch/update/B14093B/sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-bnet-bin-component-dl;sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-bnet-bin-component-dl;423205FE7C3D74D01990A1BB37273ADE;14093
</record>
</patch>


You can see the <record tag indicates the component that needs to be updated. It has the following structure:
<record program="[...Application name...]" component="[... Component name ...]">
[... URL for the dl file ...];[... Name of the dl file ...];[... MD5 hash of the dl file ...];[... version number ...]
</record>


3. The client then gets the URLs from here and downloads and install them.
4. Then it checks again and if the server returns no update XML data it means that the client is lastest version.

If the update server could not be found the launcher continues loading the game.

stormbreaker

#6
Update:
The DL file itself is an MPQ archive. It has (a minimum of) two files:


prepatch.lst - contains list of operations the updater should do. For example
extract sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-game.torrent
download sc2-0.2.0.13891-0.3.0.14093-x86-Win-enUS-game.torrent


The torrent file is also in the archive. The first line tells the updater to extract the torrent file (to the Starcraft 2 folder) and the second one is to start downloading it. It uses the blizzard downloader to do that.


The actual update file we get by downloading the torrent is also an MPQ archive. (They just love mpqs don't they  :D )


It contains the updated files in subdirectories. If an updated file is inside some of the base mpqs they aren't including the full mpq but only the updated file inside it. For example
\base\Mods\Liberty.SC2Mod\Base.SC2Data\GameData\[...file...].xml


Then in the patch.lst file every line is a file to copy. From there these files are put into the mpqs or just copied to the directory.
BlizzardComponent.xml;base/Mods/Core.SC2Mod/Base.SC2Data\BlizzardComponent.xml;base/Mods/Core.SC2Mod/Base.SC2Data
BuildId.txt;base/Mods/Core.SC2Mod/Base.SC2Data\BuildId.txt;base/Mods/Core.SC2Mod/Base.SC2Data
Assets\Effects\Protoss\BlinkIn\BlinkIn.m3;base/Mods/Liberty.SC2Mod/Base.SC2Assets\Assets\Effects\Protoss\BlinkIn\BlinkIn.m3;base/Mods/Liberty.SC2Mod/Base.SC2Assets

[...File path inside the mpq...];[...Path to the file from the root of the downloaded update mpq...];[...Path to the MPQ archive inside the Starcraft2 folder...]\n


patch.cmd contains the build numbers before and after and the Language version.


hdfiles.lst and wowtest.lst seem to contain the files that should be in the SC2 folder.


delete.lst - files to delete after the patching process.

Bobbias

Someone please archive this. This information is absolutely invaluable for someone who would like to override the default update system. I've seen plenty of private servers for different games use various out-of-game systems for distributing custom patches and stuff, but using the ingame system is so much better. I'm sure at some point people will have hacked/altered versions of SC2 for their server (provided that private SC2 servers do proliforate in the future)

I know it's not really that hard to figure this stuff out, but it'd save someone a lot of work, and should be saved somewhere that it wou'd ever get dropped from (and even if the posts are still here, if they get buried, there's little chance of someone ever finding them)