float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
i think this is my solutionᴷᵉᵏᶳ
over a bind
then in F1 typed player_name nae
as soon as the server confirmed the name change it happenedᴷᵉᵏᶳ
over a bind
then in F1 typed player_name nae
as soon as the server confirmed the name change it happened in_range<long>
is that even a safe template parameter?
can't long be 32-bit on a 32-bit computer? (edited)int64_t
debug: sizeof(int)=4 sizeof(long)=4 sizeof(int64_t)=8
UndiffItem
can happen during normal gameplay, we should in this case neither ignore the snapshot delta nor show an error message.
Instead of depending on the particular compiler doing integer wrapping, when integer overflows or underflows occur, we make it part of the design, by implementing integer wrapping with add_int_wrap
.
add_int_wrap
? I'm really not a huge fan of the random 64 assumption in theretemplate<typename T, typename U>
constexpr inline T bit_cast(U u)
{
static_assert(sizeof(T) == sizeof(U) && std::is_trivially_copyable_v<T> && std::is_trivially_copyable_v<U>);
T t;
std::memcpy(&t, &u, sizeof(T));
return t;
}
template<typename T>
constexpr inline T add_wrap(T a, T b)
{
typedef typename std::make_unsigned<T>::type unsigned_type;
return bit_cast<T>(bit_cast<unsigned_type>(a) + bit_cast<unsigned_type>(b));
}
When I use reinterpret_cast
I get error: invalid cast from type 'int' to type 'unsigned_type' {aka 'unsigned int'}
148 | return reinterpret_cast<T>(reinterpret_cast<unsigned_type>(a) + reinterpret_cast<unsigned_type>(b));
*reinterpret_cast<unsigned int*>(&a)
bit_cast
one is definitely legal. reinterpret_cast
might not be, I don't really remember nowgcc -O2
both implementations have the same assembly https://godbolt.org/z/McW3EWaqEreinterpret_cast (or equivalent explicit cast) between pointer or reference types shall not be used to reinterpret object representation in most cases because of the type aliasing rule.
https://stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule
https://stackoverflow.com/questions/14623266/why-cant-i-reinterpret-cast-uint-to-int (edited)