Allow prototype references to be actual references #196
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit is a rather big design change in how prototypes are written and used. Before this, references to other prototypes were just strings. If you wanted to get the prototype that it was referring to it was necessary to go and look it up in the hashmaps contained within GameConfig. This was doable, if inconvenient.
It would be much more convenient if, instead of going through strings and hashmaps, we could just directly access the corresponding prototype to do this. This commit makes it so this approach works.
The way it does this is like so:
The disadvantages of this approach is that the types are rather messy and that it leaks memory every time a GameConfig instance is constructed. However, the amount of memory is rather small and GameConfig should only be constructed about once for each execution of the program, so I think this downside is worth it.
In addition, GameConfig has an unsafe method to reclaim the leaked memory and actually free it. Usually there's no point in using this but it might be needed if we want to track down other memory leaks in the program.