You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a bit of a circular loading dependency when loading a gamestate, where entities require osp->game_state is already set during loading. Fix this by rearranging when the entities create the lua env (assign osp->universe, etc...) so that the load order makes more sense
The text was updated successfully, but these errors were encountered:
something to attempt over summer break , i see (wishful thinking on my part (i wish i could actually , code without 1000th bugs )) -- where is the loading implemented (what file? )
not that i will actually get anywhere (the most complicated thing i ever did in c++ was a remake of flappy bird for intro to CS )
If you follow the different calls you can quickly get to the real loading logic, which is mostly on GameState.cpp
A good example of spaghetti is the fact that osp->game_state (which you would expect is set on the launch_gamestate function!) is in fact set by the GameState itself:
This is kind of required because otherwise as entities and scenes are created, their lua code would run and that code may attempt to access osp->universe, which would not be set as the Universe belongs to the GameState. This circular dependency means that OSP may not have an universe after until the GameState load function has finished (as that creates the universe), but the GameState load may cause some lua code to run which will access osp.universe and crash the game.
The current solution is to set osp.universe within GameState (while the universe is being populated with entities), but a more elegant solution would be to separate the loading logic from any execution of lua code. For example, moving the Entity constructor lua loading code to an external function.
There's a bit of a circular loading dependency when loading a gamestate, where entities require osp->game_state is already set during loading. Fix this by rearranging when the entities create the lua env (assign osp->universe, etc...) so that the load order makes more sense
The text was updated successfully, but these errors were encountered: