Original Post
I'm sure someone has had this problem before. Here's the thing. boot.h includes global.h global.h includes data.h data.h includes map.h map.h includes pause.h pause.h includes global.h ... BUT HEY!!! When pause.h includes global.h it gets to this line in global.h : #ifndef __GLOBAL_HEADER__ (then define __GLOBAL_HEADER__ and include the file) BUT, since we defined __GLOBAL_HEADER__ in the very beginning of the global.h (when we first included it from boot.h), this file doesn't get included, AND it also didn't get to it's data definitions (because it first started including files), sh*t is on it's way ******************************* We've been trying to find a good fix for this problem and I'm wondering if anyone has any suggestions. Here's a list of our inclusion paths. (source -> dest, means that source #includes dest)
And I proposed cleaning it up like this:
And then put forward class declarations for all the game mode classes (boot, battle, map, etc) in global.h Then I think everything will be ok...? I'm not sure though. The biggest problem here is with data.h, which handles are C++<=>Lua data handling. All of our config settings and game data are stored in Lua so for the game settings to initialize global.h needs to call a function in data.h to initialize it's members, and data.h needs to include global.h so that it knows the class definition and can set those members. Is there a better way around this? Any help would be greatly appreciated, thanks! [smile]
audio.h -> utils.h
boot.h -> video.h, audio.h, global.h, utils.h, map.h, (maybe quit.h)
data.h -> video.h, audio.h, global.h, utils.h, boot.h, map.h, battle.h, menu.h
global.h -> data.h, utils.h (it may be possible to get rid of data.h)
map.h -> video.h, audio.h, global.h, pause.h, quit.h, battle.h, menu.h, scene.h
pause.h -> video.h, audio.h, global.h
quit.h -> video.h, audio.h, global.h, boot.h
scene.h -> video.h, audio.h, global.h, pause.h
utils.h -> {nothing}
video.h -> utils.h
Well at least that's the core inclusion tree. There's also more stuff in the video engine and map_editor but there doesn't seem to be a problem there yet. To get an idea of what our inclusion tree looks like, one of my staff members made this quick image:
And I proposed cleaning it up like this:
And then put forward class declarations for all the game mode classes (boot, battle, map, etc) in global.h Then I think everything will be ok...? I'm not sure though. The biggest problem here is with data.h, which handles are C++<=>Lua data handling. All of our config settings and game data are stored in Lua so for the game settings to initialize global.h needs to call a function in data.h to initialize it's members, and data.h needs to include global.h so that it knows the class definition and can set those members. Is there a better way around this? Any help would be greatly appreciated, thanks! [smile]