Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Int Types #4061

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions Shared/sdk/SharedUtil.IntTypes.h
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: Shared/sdk/SharedUtil.IntTypes.h
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
* Multi Theft Auto is available from https://multitheftauto.com/
*
*****************************************************************************/

#include <cstdint>

/*************************************************************************
Simplification of some 'unsigned' types
*************************************************************************/
// VS GCC
// Actual sizes: 32bit 64bit 64bit
typedef unsigned long ulong; // 32 32 64
typedef unsigned int uint; // 32
typedef unsigned short ushort; // 16
typedef unsigned char uchar; // 8
using ulong = unsigned long; // 32 32 64
using uint = std::uint32_t; // 32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't look safe for x64 server

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't look safe for x64 server

In general, everything is fine, if you have accurate thoughts about a possible problem, I will take note.

using ushort = std::uint16_t; // 16
using uchar = std::uint8_t; // 8

typedef unsigned long long uint64; // 64
typedef unsigned int uint32; // 32
typedef unsigned short uint16; // 16
typedef unsigned char uint8; // 8
using uint64 = std::uint64_t; // 64
using uint32 = std::uint32_t; // 32
using uint16 = std::uint16_t; // 16
using uint8 = std::uint8_t; // 8

// signed types
typedef signed long long int64; // 64
typedef signed int int32; // 32
typedef signed short int16; // 16
typedef signed char int8; // 8
using int64 = std::int64_t; // 64
using int32 = std::int32_t; // 32
using int16 = std::int16_t; // 16
using int8 = std::int8_t; // 8

// Windowsesq types
typedef unsigned char BYTE; // 8
typedef unsigned short WORD; // 16
typedef unsigned long DWORD; // 32 32 64
typedef float FLOAT; // 32
using BYTE = std::uint8_t; // 8
using WORD = std::uint16_t; // 16
using DWORD = unsigned long; // 32 32 64
using FLOAT = float; // 32

// Type: considerations:
// a) long (and therefore DWORD) is 64 bits when compiled using 64 bit GCC
8 changes: 5 additions & 3 deletions Shared/sdk/sha2.h
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@
* SUCH DAMAGE.
*/

#include <cstdint>

#ifndef SHA2_H
#define SHA2_H

@@ -46,9 +48,9 @@

#ifndef SHA2_TYPES
#define SHA2_TYPES
typedef unsigned char uint8;
typedef unsigned int uint32;
typedef unsigned long long uint64;
using uint8 = std::uint8_t;
using uint32 = std::uint32_t;
using uint64 = std::uint64_t;
#endif

#ifdef __cplusplus
Loading
Oops, something went wrong.