Handmade Hero»Forums»Code
Patrick Lahey
67 posts
Handmade Hero Tech considerations
Edited by Patrick Lahey on
I think it might be useful to have a thread that captures some of the technical issues that need to be kept in mind when using some of the techniques being demonstrated in Handmade Hero.

I will try to edit this first post to keep it up to date as the series progresses.

Live Code Editing
  1. A change to a data structure that is stored on the heap requires a full restart or special code to translate the old structure to the new
  2. A change to the platform layer code requires a full restart
  3. Pointers stored on the heap should only point back into the heap (or to something that will not be reloaded). Examples of things to watch out for are:
    1. Pointers to functions
    2. Pointers to C++ objects that contain virtual functions (they have a hidden pointer to the class's vtable)
    3. Pointers to artifacts defined in code (e.g. string literals, global/static objects, etc...)

Deterministic Playback

Given our use case, this is unlikely to be a problem but I will mention it just because it is nasty to track down if you are unaware of the issue. Getting deterministic/repeatable results from floating point operations relies not just on numerical values but also on the state of the floating point unit (and the compiler, cpu, etc... but that doesn't matter for this use case). The following is a good starting point to research the issue: Floating Point Determinism (it is by Bruce Dawson, formerly of Valve now at Google).
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Handmade Hero Tech considerations
I would add constant string pointers to the Live Code Editing list. If you do this in the game code:

1
char *Foo = "Some constant string!";


you cannot ever store a pointer to that string in the persistent block, because when hotloading occurs, the string's location will move, and you will be pointing to garbage. So any strings that need to persist across hotloads must be explicitly copied into the game memory, or something similar.

- Casey
Patrick Lahey
67 posts
Handmade Hero Tech considerations
Thanks, I've edited the post to try to capture this.