#But how to REALLY do hot reloading?

27 messages · Page 1 of 1 (latest)

tepid ore
#

I've wrote a simple hot reload dynamic library demo (video attached)

the problem with reloading the whole library is that all data written in that library gets reset each reload (the data is not retained).

of course, we can initialize that data in static main program, and then share that data via header file, but then we loose the ability to add more data in runtime.

my best guess is that we need 2 dynamic libraries and - 1st is for reloading main loop code, 2nd is for reloading initialization code,
and share initialized data between those libraries using some sort of dynamic data structure which can hold,add,remove any type of value or function.

but i wasn't able to find any examples of this type of system online ):

thoughts?

visual brookBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

tepid ore
knotty burrow
#

Well you can introduce a callback for the module to save and then reload the data.

tepid ore
#

or that

#

just save every inititial data value to a file and re-read that file.

#

sounds daunting tho

knotty burrow
#

Could be just kept in the host memory.

tepid ore
#

how?

knotty burrow
#

Have the module put its data into a data structure somewhere and let the host keep it.

tepid ore
#

oh, i already discussed about this in my post:

of course, we can initialize that data in static main program, and then share that data via header file, but then we loose the ability to add more data in runtime.

#

static main program = host

#

unless i didn't understand you correctly

knotty burrow
#

Yeah that's not what I meant.

#

How much data is totally up for the module itself to decide, the host just has the responsibility of keeping and then handing back that data.

#

The amount of data can be dynamic.

tepid ore
#

so, i need a dynamic data structure?

#

using some sort of dynamic data structure which can hold,add,remove any type of value or function.

knotty burrow
#

Kind of, doesn't need to be fancy.

#

Can be just raw buffer pointers.

tepid ore
#

so dynamic array of void*?

knotty burrow
#

Thank carefully and then try applying it.

tepid ore
#

does that mean no?

knotty burrow
#

No need to try to get my approval.

tepid ore
#

oke, i just wanted to get your opinion :L

tepid ore
#

that means i'll also need to keep track of which init data items where added in host, and do a check to not re-add same items them in module. hmmm

torn elbow
# tepid ore that means i'll also need to keep track of which init data items where added in ...

Yeah, in my experience only being able to hot reload the logic, and not the newly added data, is more than comfortable enough. Most importantly, it's relatively simple to set up in almost any language.

You could definitely have the hot reloaded code contain a save and load function though, where the save function malloc()s a struct containing all of your game's data, where you then save that pointer in the host. But when you also change the struct's layout, it isn't trivial to ensure that you aren't accidentally interpreting an old field as a new field.

So if you do go down this route, really stress test every possible edge case before you use this system.