More conversion
This commit is contained in:
+17
-43
@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef _Q_COMMON_H
|
||||
#define _Q_COMMON_H
|
||||
#include "convar.hpp"
|
||||
|
||||
// comndef.h -- general definitions
|
||||
|
||||
@@ -57,10 +58,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#define NO_COMMA
|
||||
|
||||
#define IMPL_GENERIC_FUNCS(type, suffix) \
|
||||
static inline type q_min_##suffix (type a, type b) { \
|
||||
static inline type std::min_##suffix (type a, type b) { \
|
||||
return (a < b) ? a : b; \
|
||||
} \
|
||||
static inline type q_max_##suffix (type a, type b) { \
|
||||
static inline type std::max_##suffix (type a, type b) { \
|
||||
return (a > b) ? a : b; \
|
||||
} \
|
||||
static inline type clamp_##suffix (type minval, type val, type maxval) { \
|
||||
@@ -69,30 +70,17 @@ static inline type clamp_##suffix (type minval, type val, type maxval) { \
|
||||
|
||||
GENERIC_TYPES (IMPL_GENERIC_FUNCS, NO_COMMA)
|
||||
|
||||
#define SELECT_Q_MIN(type, suffix) type: q_min_##suffix
|
||||
#define q_min(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_Q_MIN, COMMA))(a, b)
|
||||
#define SELECT_std::min(type, suffix) type: std::min_##suffix
|
||||
#define std::min(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_std::min, COMMA))(a, b)
|
||||
|
||||
#define SELECT_Q_MAX(type, suffix) type: q_max_##suffix
|
||||
#define q_max(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_Q_MAX, COMMA))(a, b)
|
||||
#define SELECT_std::max(type, suffix) type: std::max_##suffix
|
||||
#define std::max(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_std::max, COMMA))(a, b)
|
||||
|
||||
#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__)
|
||||
/* min and max macros with type checking -- based on tyrquake. */
|
||||
#define q_max(a,b) ({ \
|
||||
const __typeof(a) a_ = (a); \
|
||||
const __typeof(b) b_ = (b); \
|
||||
(void)(&a_ == &b_); \
|
||||
(a_ > b_) ? a_ : b_; \
|
||||
})
|
||||
#define q_min(a,b) ({ \
|
||||
const __typeof(a) a_ = (a); \
|
||||
const __typeof(b) b_ = (b); \
|
||||
(void)(&a_ == &b_); \
|
||||
(a_ < b_) ? a_ : b_; \
|
||||
})
|
||||
#define CLAMP(_minval, x, _maxval) ({ \
|
||||
const __typeof(x) x_ = (x); \
|
||||
const __typeof(_minval) valmin_ = (_minval);\
|
||||
@@ -104,8 +92,8 @@ GENERIC_TYPES (IMPL_GENERIC_FUNCS, NO_COMMA)
|
||||
})
|
||||
|
||||
#else
|
||||
#define q_min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define q_max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#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))
|
||||
@@ -237,17 +225,16 @@ extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args)
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern char com_token[1024];
|
||||
extern qboolean com_eof;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CPE_NOTRUNC, // return parse error in case of overflow
|
||||
CPE_ALLOWTRUNC // truncate com_token in case of overflow
|
||||
} cpe_mode;
|
||||
|
||||
const char *COM_Parse (const char *data);
|
||||
const char *COM_ParseEx (const char *data, cpe_mode mode);
|
||||
namespace common {
|
||||
std::optional<std::string> parse_token(std::istringstream &ss);
|
||||
std::string parse_string_newline(std::istringstream &ss);
|
||||
|
||||
int parse_int_newline(std::istringstream &ss);
|
||||
float parse_float_newline(std::istringstream &ss);
|
||||
}
|
||||
|
||||
|
||||
extern int com_argc;
|
||||
@@ -358,19 +345,6 @@ byte *COM_LoadMallocFile (const char *path, unsigned int *path_id);
|
||||
// Loads in "t" mode so CRLF to LF translation is performed on Windows.
|
||||
byte *COM_LoadMallocFile_TextMode_OSPath (const char *path, long *len_out);
|
||||
|
||||
// Attempts to parse an int, followed by a newline.
|
||||
// Returns advanced buffer position.
|
||||
// Doesn't signal parsing failure, but this is not needed for savegame loading.
|
||||
const char *COM_ParseIntNewline(const char *buffer, int *value);
|
||||
|
||||
// Attempts to parse a float followed by a newline.
|
||||
// Returns advanced buffer position.
|
||||
const char *COM_ParseFloatNewline(const char *buffer, float *value);
|
||||
|
||||
// Parse a string of non-whitespace into com_token, then tries to consume a
|
||||
// newline. Returns advanced buffer position.
|
||||
const char *COM_ParseStringNewline(const char *buffer);
|
||||
|
||||
|
||||
#define FS_ENT_NONE (0)
|
||||
#define FS_ENT_FILE (1 << 0)
|
||||
@@ -403,7 +377,7 @@ char *FS_fgets(char *s, int size, fshandle_t *fh);
|
||||
long FS_filelength (fshandle_t *fh);
|
||||
|
||||
|
||||
extern struct cvar_s registered;
|
||||
extern convar registered;
|
||||
extern qboolean standard_quake, rogue, hipnotic;
|
||||
extern qboolean fitzmode;
|
||||
/* if true, run in fitzquake mode disabling custom quakespasm hacks */
|
||||
|
||||
Reference in New Issue
Block a user