In case anyone else has an issue with live reloading and function pointers I ended up implementing what mmozeiko was suggesting. I would just find the appropriate function pointers and upon dll reloading I would set these pointers to the new function addresses. Fox anyone curious my specific fix looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 | if(GlobalPlatformServices->ReloadedDLL || GameInput->InitialInputPlaybackAfterDLLReload)
{
GlobalPlatformServices->ReloadedDLL = false;
GameInput->InitialInputPlaybackAfterDLLReload = false;
for(i32 timelineIndex{0}; timelineIndex < GameState->AnimationState->tracks[0]->animation->timelinesCount; ++timelineIndex)
{
spTimeline *Timeline = GameState->AnimationState->tracks[0]->animation->timelines[timelineIndex];
switch (Timeline->type)
{
case SP_TIMELINE_ROTATE:
{
VTABLE(spTimeline, Timeline)->apply = _spRotateTimeline_apply;
VTABLE(spTimeline, Timeline)->getPropertyId = _spRotateTimeline_getPropertyId;
}
break;
case SP_TIMELINE_SCALE:
{
VTABLE(spTimeline, Timeline)->apply = _spScaleTimeline_apply;
VTABLE(spTimeline, Timeline)->getPropertyId = _spScaleTimeline_getPropertyId;
}
break;
case SP_TIMELINE_SHEAR:
{
VTABLE(spTimeline, Timeline)->apply = _spShearTimeline_apply;
VTABLE(spTimeline, Timeline)->getPropertyId = _spShearTimeline_getPropertyId;
}
break;
case SP_TIMELINE_TRANSLATE:
{
VTABLE(spTimeline, Timeline)->apply = _spTranslateTimeline_apply;
VTABLE(spTimeline, Timeline)->getPropertyId = _spTranslateTimeline_getPropertyId;
}
break;
case SP_TIMELINE_EVENT:
{
VTABLE(spTimeline, Timeline)->apply = _spEventTimeline_apply;
VTABLE(spTimeline, Timeline)->getPropertyId = _spEventTimeline_getPropertyId;
}
break;
case SP_TIMELINE_ATTACHMENT:
{
VTABLE(spTimeline, Timeline)->apply = _spAttachmentTimeline_apply;
VTABLE(spTimeline, Timeline)->getPropertyId = _spAttachmentTimeline_getPropertyId;
}
break;
};
};
};
|
While this code is obviously specific to my project, just focus on the fact that I'm taking function addresses (_spAttachmentTimeline_appy, _spEventTimeline_apply, etc.) and just copying them to the current object's function pointer.
Notice that I also have a flag for telling if I'm currently reloading my dll while in inputplackback mode. This is also something to keep in mind depending on how you are playing back your recorded input state for the looped live code editing. For me, I'm just continually copying the initial game_state of my game when I first started to record my input and setting that as my game_state during each turn of my input plackback. This means, during inputplayback when trying to reload my dll again, my old function pointer addresses will be reset to before the dll reload occurred. In this case I need to make sure to reset the function pointers again to avoid a crash during input playback and dll reloading.