This will ensure that the pointer you are casting actually is of the type you are casting it to, or it will raise an assertion error otherwise. That would have caught the incorrect-type error from your first attempt.
Right, that’s what I mean. The result of get_ptr() isn’t an OdeCollisionEntry, and shouldn’t be cast to one. If you just use a static cast, it will crash mysteriously. If you use the DCAST macro, it should at least tell you that you’re casting a pointer to the wrong type before it crashes mysteriously.
The weird thing is that I didn’t get any crash when doing it the wrong way… my pgm run normally, I just got totally wrong collision results reported back to me.
Well, that’s just the luck of the draw. When you miscast a pointer in C++, you get technically “undefined behavior”, which often means a crash, but it might just mean weird behavior.