I want to put all the atlas resources in separate archives so that the player does not download what has not changed every time I update the game. So I have a few questions:
If the atlases are unchanged, but only the code changes, do the atlas resources, their hexDigest, remain unchanged in a new build?
If atlas resources were built in one version of the engine and the rest of the resources are from another version, will there be problems with this?
From what I observed, the resource hexDigest will not be changed in a new build, event if the resource content is modified. Not sure when we change the engine version.
Correct, a resource which hasn’t changed will have the same hexDigest
It depends. If the data format has changed it will obviously be a problem, but otherwise not. We very rarely change the data format, but things have changed a couple of time recently since we introduced both multi-page atlases and multi-texture support recently. We leave it up to the developer to validate both the integrity of the archive, resources and that resources are compatible with the version of the engine the game is using.
Since you are also working on separating archives, I have a script you may need it sometimes. It collects only different resources compared with the old graph.json.
One thing I’m noticing is that there are some resources that have been changed hexDigest but I haven’t changed its content.
make_update.py
import os
import sys
import json
import shutil
current_dir = os.path.dirname(os.path.realpath(__file__))
extract_dir = os.path.join(current_dir, 'tmp1')
working_dir = os.path.join(current_dir, 'tmp2')
if __name__ == '__main__':
# requirement: python 3
# usage: python make_update.py [old_graph_filename] [new_graph_filename] [source_zip]
# example: python make_update.py v10.graph.json v11.graph.json v11_full.zip
# output: update.zip (contains only new & changed files)
old_graph_filename = sys.argv[1]
new_graph_filename = sys.argv[2]
source_zip = sys.argv[3]
with open(old_graph_filename) as user_file:
contents = json.loads(user_file.read())
old_graph = {}
for el in contents:
old_graph[el['hexDigest']] = el
with open(new_graph_filename) as user_file:
contents = json.loads(user_file.read())
new_graph = {}
for el in contents:
new_graph[el['hexDigest']] = el
changed_list = []
for key in new_graph:
if key not in old_graph and new_graph[key]['isInMainBundle'] == False:
changed_list.append(new_graph[key])
if len(changed_list) > 0:
shutil.rmtree(extract_dir, ignore_errors=True)
shutil.rmtree(working_dir, ignore_errors=True)
os.makedirs(working_dir)
shutil.unpack_archive(source_zip, extract_dir)
for el in changed_list:
print(el['hexDigest'] + ' - ' + el['path'])
shutil.copy(extract_dir + '/' + el['hexDigest'], working_dir)
shutil.copy(extract_dir + '/liveupdate.game.dmanifest', working_dir)
shutil.make_archive('update', 'zip', working_dir)
shutil.rmtree(extract_dir)
shutil.rmtree(working_dir)