Descent3
Descent3 copied to clipboard
Move away from C style arrays
There are many classic C arrays allocated with fixes sizes, and some conditions that simply lack sane bounds checking, this leads to many potential invalid memory access exceptions, and is the culprit load file crash for Linux.
Instead of C arrays, use C++ std::array or std::vector classes instead.
I think this is a good idea in theory, but I think it will take a massive amount of work. There are a lot of pointers to arrays used. Something I think we can look at in the future, but I think we have bigger fish to fry for a while.
Isn't this part of moving towards modern C++?
We can enforce using modern C++ for newly added code, but re-writing existing code for the sake of it is likely to introduce more problems that it would solve
I thought the whole codebase was basically going to be re-written into modern C++, not just mixing it. I know for now, lots of legacy stuff just needs to be fixed to get things at stable point. It is why I thought of unit testing should be started early on, so later when classic code is moved over to modern C++, the tests can ensure things still correctly work.
Descent3 is around 1 million lines of C++, it'll be a while before we rewrite all of that =)
I do agree that unit tests are a priority, and we're trying to figure out the best way to do them.
I understand there is a lot of code, but how much of that is in the core system? What about moving the core engine into a separate library, like making it a cmake submodule.
Since we are using cmake here, you can leverage Gtest with cmake: https://google.github.io/googletest/quickstart-cmake.html