cinera_handmade.network/cmuratori/hero/code/code465.hmml

63 lines
6.9 KiB
Plaintext
Raw Permalink Normal View History

[video output=day465 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Updating HHAs from V0 to V1" vod_platform=youtube id=x9NKVi4Dib4 annotator=Miblo]
2018-07-23 22:02:48 +00:00
[0:01][Recap and set the stage for the day][:speech]
[1:47][Take a look at the .hha files in our data directory][:"asset loading" :speech]
[3:06][Demo hhaedit creating a new local.hha file][:"asset loading" :run]
[4:00][:Run the game, hit our AssetCount mismatch assertion in AllocateGameAssets(), and plan out the day][:"asset loading"]
[5:28][Dive into debugging the asset updating bug][:"asset loading" :research]
[7:23][Make WriteModificationsToHHA() account for the initial null asset][:"asset loading"]
[9:13][Create a new .hha file, :run the game twice and again hit our AssetCount mismatch assertion in AllocateGameAssets()][:"asset loading"]
[9:41][Separate the AssetTypeCount from AssetCount in WriteModificationsToHHA()][:"asset loading"]
[12:19][Perform our .hha creation / game running cycle, and again hit the AssetCount mismatch assertion in AllocateGameAssets()][:"asset loading" :run]
[13:31][Create a debug directory containing only the data and our created local.hha][:admin :"asset loading"]
[14:55][Step through AllocateGameAssets() and inspect our local.hha to see that the OnePastLastAssetIndex is wrong][:"asset loading" :run]
[17:17][Make WriteModificationsToHHA() correctly set OnePastLastAssetIndex][:"asset loading"]
[17:59][Note the F8 command-completion shortcut in Command Prompt][:speech]
[18:32][Create a new local.hha and ensure that we're all good][:"asset loading" :run]
[21:48][Determine to write out our metadata and nail down the tag situation, and consider the possibility of enabling hhaedit to upgrade our .hha file format][:"asset loading" :speech]
[24:11][Dive into tagging, possibly storing tags for entire sprite sheets rather than individual sprites][:art :"asset loading" :speech]
[28:32][A few words on trying different solutions to problems][:speech]
[31:28][Consider importing assets as named by the artist][:"asset loading" :speech]
[33:01][Art Space][:"asset loading" :blackboard :"entity system"]
[38:49][Integer-based IDs, that may later be associated with picking][:"asset loading" :blackboard :"entity system"]
[39:17][Merging of asset packs, and hierarchical tags][:"asset loading" :blackboard :"entity system"]
[42:33][Asset annotations][:"asset loading" :"entity system" :speech]
[45:01][Introduce hha_asset_markup struct for asset annotations, and add a Tag_Primacy asset_tag_id][:"asset loading"]
[50:40][Augment our hha_header with Annotations (renaming hha_asset_markup to hha_annotation) setting us up for HHA file format upgrading][:"asset loading"]
[53:40][Consider whether we need TypeIDs on our assets at all][:"asset loading" :speech]
[56:49][Consider using TypeIDs to partition the assets][:"asset loading" :speech]
[57:50][Add Tag_DataType asset_tag_id and an asset_data_type_id enum][:"asset loading"]
[1:00:14][Set up to perform .hha file format upgrading, creating handmade_file_formats.h and separating the .hha struct version into their own files][:"asset loading"]
[1:02:31][Introduce ReadHHA(), WriteHHA() and FileExists()][:"asset loading" :"file io"]
[1:06:12][:Research file existence checking in the CRT][:"file io"]
[1:09:10][Implement FileExists() and set up to dump the .hha file contents to stdout][:"file io"]
[1:17:00][Augment loaded_hha with TagCount and AssetCount, and hha_annotation with SourceFileBaseName, AssetName, AssetDescription and Author, and their counts][:"asset loading"]
[1:19:38][Implement ReadHHA() and dump the MagicValue and Version to stdout][:"asset loading"]
[1:26:38][:Run hhaedit -info to see our info dump][:"asset loading"]
[1:27:01][Create a fresh dummy.hha and check out its mini info dump][:"asset loading" :run]
[1:27:51][Make ReadHHA() read in the file using ReadEntireFile() before extracting the MagicValue and SourceVersion and conditionally calling ReadHHA_V0() or ReadHHA_V1()[ref
site="C++ Reference"
page=fseek
url=http://www.cplusplus.com/reference/cstdio/fseek/]][:"asset loading" :"file io"]
[1:33:06][Enable ReadHHA_V0() to read in and upgrade the .hha file to version 1, and augment loaded_hha with a Valid boolean][:"asset loading"]
[1:51:04][Implement WriteHHA()][:"asset loading"]
[1:55:46][Consider our need to copy data from the data store forward][:"asset loading" :speech]
[1:58:28][Introduce loaded_hha_annotation for ReadHHA_V0() to use][:"asset loading"]
[2:00:46][Define our hha structs as the old ones][:"asset loading"]
[2:03:02][:Run it and hit our InvalidCodePath in AllocateGameAssets()][:"asset loading"]
[2:05:09][Step through AllocateGameAssets() and inspect the File to see that it's using the wrong sizes][:"asset loading"]
[2:06:07][Correctly pragma pack the hha structs everywhere and redefine HHA_VERSION 0][:"asset loading" :"data structure"]
[2:07:06][:Run it to see that we're loading correctly][:"asset loading"]
[2:08:03][Augment hha_annotation with FileDate, SpriteSheetX and SpriteSheetY][:"asset loading"]
[2:09:37][Q&A][:speech]
[2:09:56][@frostyninja][Q: So, instead of tags, why not relegate the logic of picking a range, or random bunch, of specific assets to the part that pulls assets in - e.g. when making a new entity or what have you, have a way to specify hey pick one from these specific assets here (by path / name or some other identifier). Obviously comes with its own issues, might not be what you want, and all but is it an idea you've entertained?][:"asset loading"]
[2:12:24][@steplery][@handmade_hero Do you have any plans about adding scripting? Which :language you going to use for scripting in case if you have such plans (or will everything be C / C++ only)?]
[2:12:35][@centhusiast][Q: Are we going to use typedef for the enums? Also, is an unnamed union inside a struct legal in terms of ANSI C?][:language]
[2:13:48][@desuused][Q: Will HHA contain hashes / checksums for original input files? This might allow a nice way to only update the changed assets, even if file timestamps are off][:"asset loading"]
[2:14:02][Augement hha_annotation with SourceFileChecksum][:"asset loading"]
[2:15:14][@frostyninja][Q: If the entity holds a reference into a table that looks up the asset then that would work with hotloading, no?][:"asset loading"]
[2:15:26][Art Space][:"asset loading" :blackboard :"entity system"]
[2:15:48][@frostyninja][Also, what I meant was go away with the specific code-side defined tags and leave picking down to reference specifically by path or asset name that's based on the source asset file][:"asset loading"]
[2:16:09][@jessef][Q: I implemented an :animation system based on your tag system where every animation frame is tagged with a number between 0-tau and as the t value loop goes up it says "hey go get the next sprite" but not sure if this is a good idea? Do you see any problems with this, and / or how do 2D animation system normally know which sprite to grab?][:"asset loading"]
[2:18:26][Close it down][:speech]
[/video]