Whereas the analyzer will find it immediately after building the project and running incremental analysis. Just imagine how hard it will be to look for such a flaw at the end of the working day. Here I broke lines so that everything fit exactly in the width of the line.
AMNESIA THE DARK DESCENT LENGTH CODE
Note that all the expressions in the original code were written in a line. Here's a pic for you to avoid accidentally spying on the answer:ĭid you find a bug? So, in the last return, there is a comparison using aObjectDataA on both sides. Return aObjectDataA.mpPhysicsMaterial GetVertexBuffer() If( aObjectDataA.mpPhysicsMaterial != aObjectDataB.mpPhysicsMaterial) Return aObjectDataA.mpObject->GetRenderFlagBit(.) != aObjectDataB.mpObject->GetRenderFlagBit(.)) If( aObjectDataA.mpObject->GetRenderFlagBit(.) Try to see for yourself where the error was made in the function: static bool SortStaticSubMeshesForBodies(const. I will cite the entire function for clarity. Let's start with an example where the entire function consists of comparing method results and fields values of two objects aObjectDataA and aObjectDataB. After all, other developers may be as clueless as I am. Once they confused both the analyzer and me, at least a comment could be of use. Some cases may be due to the internal logic of the game itself. There were a lot of suspicious places that looked like inattentive copying. The main reason for these errors is the " last line effect". The better half of errors found by the analyzer in these projects was copy-paste errors. So almost all the errors that I will cite further take place in both projects. Also check out the articles by my colleagues about checking source code of games.Īfter checking, it turned out that a large amount of code overlaps between "The Dark Descent" and "A Machine For Pigs", and the reports for these two projects were very similar. So, if you are interested in what errors are made in games, you can read my previous articles. I especially like delving into source code of games. In case someone is not familiar with PVS-Studio yet, this is a static analyzer that looks for errors and suspicious places in source code of programs. But I liked watching this game run through videos on YouTube. The reason is that in horror games I play by one algorithm: install, run for five minutes, exit by "alt+f4" at the first creepy moment and delete the game. Frankly speaking, I have never been able to play through it, even a bit. "Amnesia: The Dark Descent" was released in 2010 and became a cult game in the survival horror genre. Especially since the new part of this game-series - " Amnesia: Rebirth" is released on the 20th of October (and at the moment of posting this article the game is already released). After seeing the news on Reddit that the source code of the games " Amnesia: The Dark Descent" and " Amnesia: A Machine for Pigs" was released, I couldn't pass by and not check this code using PVS-Studio, and at the same time write an article about it.