Even more conversion, lots of superfluous macro removal

This commit is contained in:
iikorni
2026-08-29 23:14:23 -05:00
parent 70e5c02355
commit de75b014b3
102 changed files with 7060 additions and 8179 deletions
+15 -43
View File
@@ -79,30 +79,13 @@ GENERIC_TYPES (IMPL_GENERIC_FUNCS, NO_COMMA)
#define SELECT_CLAMP(type, suffix) type: clamp_##suffix
#define CLAMP(minval, val, maxval) _Generic((minval) + (val) + (maxval), \
GENERIC_TYPES (SELECT_CLAMP, COMMA))(minval, val, maxval)
#elif defined(__GNUC__)
#define CLAMP(_minval, x, _maxval) ({ \
const __typeof(x) x_ = (x); \
const __typeof(_minval) valmin_ = (_minval);\
const __typeof(_maxval) valmax_ = (_maxval);\
(void)(&x_ == &valmin_); \
(void)(&x_ == &valmax_); \
(x_ < valmin_) ? valmin_ : \
(x_ > valmax_) ? valmax_ : x_; \
})
#else
#define std::min(a, b) (((a) < (b)) ? (a) : (b))
#define std::max(a, b) (((a) > (b)) ? (a) : (b))
#define CLAMP(_minval, x, _maxval) \
((x) < (_minval) ? (_minval) : \
(x) > (_maxval) ? (_maxval) : (x))
#endif
// TODO: Maybe some special casing on an std::vector?
typedef struct sizebuf_s
{
qboolean allowoverflow; // if false, do a Sys_Error
qboolean overflowed; // set to true if the buffer size failed
bool allowoverflow; // if false, do a Sys_Error
bool overflowed; // set to true if the buffer size failed
byte *data;
int maxsize;
int cursize;
@@ -154,7 +137,7 @@ void Vec_Free (void **pvec);
//============================================================================
extern qboolean host_bigendian;
extern bool host_bigendian;
extern short (*BigShort) (short l);
extern short (*LittleShort) (short l);
@@ -176,7 +159,7 @@ void MSG_WriteAngle (sizebuf_t *sb, float f, unsigned int flags);
void MSG_WriteAngle16 (sizebuf_t *sb, float f, unsigned int flags); //johnfitz
extern int msg_readcount;
extern qboolean msg_badread; // set if a read goes beyond end of message
extern bool msg_badread; // set if a read goes beyond end of message
void MSG_BeginReading (void);
int MSG_ReadChar (void);
@@ -192,18 +175,6 @@ float MSG_ReadAngle16 (unsigned int flags); //johnfitz
//============================================================================
void Q_memset (void *dest, int fill, size_t count);
void Q_memcpy (void *dest, const void *src, size_t count);
int Q_memcmp (const void *m1, const void *m2, size_t count);
void Q_strcpy (char *dest, const char *src);
void Q_strncpy (char *dest, const char *src, int count);
int Q_strlen (const char *str);
char *Q_strrchr (const char *s, char c);
void Q_strcat (char *dest, const char *src);
int Q_strcmp (const char *s1, const char *s2);
int Q_strncmp (const char *s1, const char *s2, int count);
int Q_atoi (const char *str);
float Q_atof (const char *str);
#include "strl_fn.hpp"
@@ -225,10 +196,14 @@ extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args)
//============================================================================
extern qboolean com_eof;
extern bool com_eof;
namespace common {
void init();
std::optional<size_t> check_param(std::string_view parm);
std::optional<std::string> parse_token(std::istringstream &ss);
std::string parse_string_newline(std::istringstream &ss);
@@ -247,9 +222,6 @@ extern int safemode;
-nomouse, -nojoy, -nolan
*/
int COM_CheckParm (const char *parm);
void COM_Init (void);
void COM_InitArgv (int argc, char **argv);
void COM_InitFilesystem (void);
@@ -274,7 +246,7 @@ void LOC_Init (void);
void LOC_Shutdown (void);
const char* LOC_GetRawString (const char *key);
const char* LOC_GetString (const char *key);
qboolean LOC_HasPlaceholders (const char *str);
bool LOC_HasPlaceholders (const char *str);
size_t LOC_Format (const char *format, const char* (*getarg_fn)(int idx, void* userdata), void* userdata, char* out, size_t len);
//============================================================================
@@ -317,7 +289,7 @@ extern int file_from_pak; // global indicating that file came from a pak
void COM_WriteFile (const char *filename, const void *data, int len);
int COM_OpenFile (const char *filename, int *handle, unsigned int *path_id);
int COM_FOpenFile (const char *filename, FILE **file, unsigned int *path_id);
qboolean COM_FileExists (const char *filename, unsigned int *path_id);
bool COM_FileExists (const char *filename, unsigned int *path_id);
void COM_CloseFile (int h);
// these procedures open a file using COM_FindFile and loads it into a proper
@@ -359,7 +331,7 @@ byte *COM_LoadMallocFile_TextMode_OSPath (const char *path, long *len_out);
typedef struct _fshandle_t
{
FILE *file;
qboolean pak; /* is the file read from a pak */
bool pak; /* is the file read from a pak */
long start; /* file or data start position */
long length; /* file or data size */
long pos; /* current position relative to start */
@@ -378,8 +350,8 @@ long FS_filelength (fshandle_t *fh);
extern convar registered;
extern qboolean standard_quake, rogue, hipnotic;
extern qboolean fitzmode;
extern bool standard_quake, rogue, hipnotic;
extern bool fitzmode;
/* if true, run in fitzquake mode disabling custom quakespasm hacks */
#endif /* _Q_COMMON_H */