Vega-strike-engine-source: opcode collision system: Use `int32_t` or similar instead of `int`, where appropriate

Created on 27 Oct 2020  路  3Comments  路  Source: vegastrike/Vega-Strike-Engine-Source

According to a comment in engine/src/cmd/collide2/Stdafx.h, the OPCODE collision system assumes that sizeof(float) == sizeof(int) == sizeof(unsigned int) == sizeof(dword). On 64-bit systems, I'm pretty sure that this assumption is incorrect. That may well be why the collision system hasn't been working correctly.

I think we should replace all instances of int with int32_t, and replace unsigned int with uint32_t (https://en.cppreference.com/w/cpp/types/integer). This appears to be the C++11 way to do it. Hopefully the collision system will then start working better again.

bug

Most helpful comment

As per discussion on Gitter, making this a priority to fix in 0.9.x.

All 3 comments

@stephengtuggy I fully agree we should be using standard types (uint32/int32, etc) instead of ephemeral types (int, unsigned int, etc).

And yes, on a 64-bit system an int is 64-bits versus the 32-bits on a 32-bit system; a DWORD is only 32-bits while a QWORD (Quad Word) is 64-bits. A float probably stays the same size as its defined by the IEEE Floating Point standard.

@BenjamenMeyer OK, sounds good.

As per discussion on Gitter, making this a priority to fix in 0.9.x.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  23Comments

nabaco picture nabaco  路  27Comments

BenjamenMeyer picture BenjamenMeyer  路  30Comments

BenjamenMeyer picture BenjamenMeyer  路  18Comments

BenjamenMeyer picture BenjamenMeyer  路  28Comments