From: cloudwalk Date: Tue, 26 May 2020 16:41:57 +0000 (+0000) Subject: Clean up qtypes.h. Use stdbool.h on non-MSVC. Replace allcaps with lowercase X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5225f7ec9697b2a65a524956d6ee95c267d88145;p=xonotic%2Fdarkplaces.git Clean up qtypes.h. Use stdbool.h on non-MSVC. Replace allcaps with lowercase Last I checked, stdbool.h is only unavailable on Windows MSVC, so we'll define bool ourselves in that case. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12590 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/common.c b/common.c index 4a05368b..090f0970 100644 --- a/common.c +++ b/common.c @@ -1879,7 +1879,7 @@ COM_StringLengthNoColors(const char *s, size_t size_s, qboolean *valid) { case 0: if(valid) - *valid = TRUE; + *valid = true; return len; case STRING_COLOR_TAG: ++s; @@ -1899,7 +1899,7 @@ COM_StringLengthNoColors(const char *s, size_t size_s, qboolean *valid) case 0: // ends with unfinished color code! ++len; if(valid) - *valid = FALSE; + *valid = false; return len; case STRING_COLOR_TAG: // escaped ^ ++len; @@ -1945,17 +1945,17 @@ all characters until the zero terminator. qboolean COM_StringDecolorize(const char *in, size_t size_in, char *out, size_t size_out, qboolean escape_carets) { -#define APPEND(ch) do { if(--size_out) { *out++ = (ch); } else { *out++ = 0; return FALSE; } } while(0) +#define APPEND(ch) do { if(--size_out) { *out++ = (ch); } else { *out++ = 0; return false; } } while(0) const char *end = size_in ? (in + size_in) : NULL; if(size_out < 1) - return FALSE; + return false; for(;;) { switch((in == end) ? 0 : *in) { case 0: *out++ = 0; - return TRUE; + return true; case STRING_COLOR_TAG: ++in; switch((in == end) ? 0 : *in) @@ -1979,7 +1979,7 @@ COM_StringDecolorize(const char *in, size_t size_in, char *out, size_t size_out, if(escape_carets) APPEND(STRING_COLOR_TAG); *out++ = 0; - return TRUE; + return true; case STRING_COLOR_TAG: // escaped ^ APPEND(STRING_COLOR_TAG); // append a ^ twice when escaping diff --git a/jpeg.c b/jpeg.c index 8eeb6d7b..effab6a1 100644 --- a/jpeg.c +++ b/jpeg.c @@ -559,7 +559,7 @@ static jboolean JPEG_FillInputBuffer (j_decompress_ptr cinfo) cinfo->src->next_input_byte = jpeg_eoi_marker; cinfo->src->bytes_in_buffer = 2; - return TRUE; + return true; } static void JPEG_SkipInputData (j_decompress_ptr cinfo, long num_bytes) @@ -624,7 +624,7 @@ unsigned char* JPEG_LoadImage_BGRA (const unsigned char *f, int filesize, int *m cinfo.err = qjpeg_std_error (&jerr); cinfo.err->error_exit = JPEG_ErrorExit; JPEG_MemSrc (&cinfo, f, filesize); - qjpeg_read_header (&cinfo, TRUE); + qjpeg_read_header (&cinfo, true); cinfo.scale_num = 1; cinfo.scale_denom = (1 << submip); qjpeg_start_decompress (&cinfo); @@ -848,7 +848,7 @@ qboolean JPEG_SaveImage_preflipped (const char *filename, int width, int height, cinfo.in_color_space = JCS_RGB; cinfo.input_components = 3; qjpeg_set_defaults (&cinfo); - qjpeg_set_quality (&cinfo, (int)(scr_screenshot_jpeg_quality.value * 100), TRUE); + qjpeg_set_quality (&cinfo, (int)(scr_screenshot_jpeg_quality.value * 100), true); qjpeg_simple_progression (&cinfo); // turn off subsampling (to make text look better) diff --git a/libcurl.c b/libcurl.c index 3d8de2b0..b8f36dc2 100644 --- a/libcurl.c +++ b/libcurl.c @@ -228,7 +228,7 @@ downloadinfo; static downloadinfo *downloads = NULL; static int numdownloads = 0; -static qboolean noclear = FALSE; +static qboolean noclear = false; static int numdownloads_fail = 0; static int numdownloads_success = 0; @@ -1130,7 +1130,7 @@ void Curl_Run(void) double maxspeed; downloadinfo *di; - noclear = FALSE; + noclear = false; if(!cl_curl_enabled.integer) return; @@ -1493,9 +1493,9 @@ static void Curl_Curl_f(cmd_state_t *cmd) { dpsnprintf(donecommand, sizeof(donecommand), "connect %s", cls.netcon->address); Curl_CommandWhenDone(donecommand); - noclear = TRUE; + noclear = true; CL_Disconnect(); - noclear = FALSE; + noclear = false; Curl_CheckCommandWhenDone(); } else diff --git a/menu.c b/menu.c index 60922547..be6c3c01 100644 --- a/menu.c +++ b/menu.c @@ -5227,7 +5227,7 @@ void MVM_error_cmd(const char *format, ...) key_dest = key_game; // init the normal menu now -> this will also correct the menu router pointers - MR_SetRouting (TRUE); + MR_SetRouting (true); // reset the active scene, too (to be on the safe side ;)) R_SelectScene( RST_CLIENT ); @@ -5450,7 +5450,7 @@ void MR_Restart(void) { if(MR_Shutdown) MR_Shutdown (); - MR_SetRouting (FALSE); + MR_SetRouting (false); } static void MR_Restart_f(cmd_state_t *cmd) @@ -5610,7 +5610,7 @@ void MR_Init(void) // the normal quake menu only the first time // COMMANDLINEOPTION: Client: -useqmenu causes the first time you open the menu to use the quake menu, then reverts to menu.dat (if forceqmenu is 0) if(COM_CheckParm("-useqmenu")) - MR_SetRouting (TRUE); + MR_SetRouting (true); else - MR_SetRouting (FALSE); + MR_SetRouting (false); } diff --git a/prvm_cmds.c b/prvm_cmds.c index 73d0a89a..ec68d188 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -2211,7 +2211,7 @@ void VM_strdecolorize(prvm_prog_t *prog) // Prepare Strings VM_SAFEPARMCOUNT(1,VM_strdecolorize); szString = PRVM_G_STRING(OFS_PARM0); - COM_StringDecolorize(szString, 0, szNewString, sizeof(szNewString), TRUE); + COM_StringDecolorize(szString, 0, szNewString, sizeof(szNewString), true); PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, szNewString); } @@ -4908,7 +4908,7 @@ void VM_buf_copy (prvm_prog_t *prog) ======================== VM_buf_sort sort buffer by beginnings of strings (cmplength defaults it's length) -"backward == TRUE" means that sorting goes upside-down +"backward == true" means that sorting goes upside-down void buf_sort(float bufhandle, float cmplength, float backward) = #464; ======================== */ @@ -5047,7 +5047,7 @@ void VM_bufstr_set (prvm_prog_t *prog) ======================== VM_bufstr_add adds string to buffer in first free slot and returns its index -"order == TRUE" means that string will be added after last "full" slot +"order == true" means that string will be added after last "full" slot float bufstr_add(float bufhandle, string str, float order) = #467; ======================== */ @@ -5681,7 +5681,7 @@ void VM_uncolorstring (prvm_prog_t *prog) // Prepare Strings VM_SAFEPARMCOUNT(1, VM_uncolorstring); szString = PRVM_G_STRING(OFS_PARM0); - COM_StringDecolorize(szString, 0, szNewString, sizeof(szNewString), TRUE); + COM_StringDecolorize(szString, 0, szNewString, sizeof(szNewString), true); PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, szNewString); } diff --git a/prvm_edict.c b/prvm_edict.c index a5a7b821..9d81ef04 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -2469,7 +2469,7 @@ fail: ; } - prog->loaded = TRUE; + prog->loaded = true; PRVM_UpdateBreakpoints(prog); diff --git a/qtypes.h b/qtypes.h index f391a40a..d4fa148e 100644 --- a/qtypes.h +++ b/qtypes.h @@ -2,24 +2,20 @@ #ifndef QTYPES_H #define QTYPES_H -#undef true -#undef false - #ifndef __cplusplus -typedef enum qboolean_e {false, true} qboolean; +#ifdef _MSC_VER +typedef enum {false, true} bool; #else -typedef bool qboolean; +#include #endif +#endif +typedef bool qboolean; + #ifndef NULL #define NULL ((void *)0) #endif -#ifndef FALSE -#define FALSE false -#define TRUE true -#endif - // up / down #define PITCH 0 diff --git a/sv_main.c b/sv_main.c index 3496bc2c..b10a67d9 100644 --- a/sv_main.c +++ b/sv_main.c @@ -2030,7 +2030,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t // angle fixing was requested by global thinking code... // so store the current angles for later use VectorCopy(PRVM_serveredictvector(ent, angles), host_client->fixangle_angles); - host_client->fixangle_angles_set = TRUE; + host_client->fixangle_angles_set = true; // and clear fixangle for the next frame PRVM_serveredictfloat(ent, fixangle) = 0; @@ -2041,7 +2041,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t MSG_WriteByte (msg, svc_setangle); for (i=0 ; i < 3 ; i++) MSG_WriteAngle (msg, host_client->fixangle_angles[i], sv.protocol); - host_client->fixangle_angles_set = FALSE; + host_client->fixangle_angles_set = false; } // the runes are in serverflags, pack them into the items value, also pack diff --git a/sv_phys.c b/sv_phys.c index 94587293..6d14da1d 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -2993,7 +2993,7 @@ void SV_Physics_ClientMove(void) // angle fixing was requested by physics code... // so store the current angles for later use VectorCopy(PRVM_serveredictvector(ent, angles), host_client->fixangle_angles); - host_client->fixangle_angles_set = TRUE; + host_client->fixangle_angles_set = true; // and clear fixangle for the next frame PRVM_serveredictfloat(ent, fixangle) = 0; @@ -3052,7 +3052,7 @@ static void SV_Physics_ClientEntity_PostThink(prvm_edict_t *ent) // angle fixing was requested by physics code... // so store the current angles for later use VectorCopy(PRVM_serveredictvector(ent, angles), host_client->fixangle_angles); - host_client->fixangle_angles_set = TRUE; + host_client->fixangle_angles_set = true; // and clear fixangle for the next frame PRVM_serveredictfloat(ent, fixangle) = 0; diff --git a/thread_win.c b/thread_win.c index 8564ca19..ff1be87e 100644 --- a/thread_win.c +++ b/thread_win.c @@ -53,7 +53,7 @@ int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline) #ifdef THREADDEBUG Sys_PrintfToTerminal("%p mutex unlock %s:%i\n" , mutex, filename, fileline); #endif - return (ReleaseMutex(mutex) == FALSE) ? -1 : 0; + return (ReleaseMutex(mutex) == false) ? -1 : 0; } typedef struct thread_semaphore_s diff --git a/utf8lib.c b/utf8lib.c index e552785d..4099d0a7 100644 --- a/utf8lib.c +++ b/utf8lib.c @@ -800,7 +800,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid) { case 0: if(valid) - *valid = TRUE; + *valid = true; return len; case STRING_COLOR_TAG: ++s; @@ -820,7 +820,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid) case 0: // ends with unfinished color code! ++len; if(valid) - *valid = FALSE; + *valid = false; return len; case STRING_COLOR_TAG: // escaped ^ ++len; @@ -858,7 +858,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid) { // we CAN end up here, if an invalid char is between this one and the end of the string if(valid) - *valid = TRUE; + *valid = true; return len; } @@ -866,7 +866,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid) { // string length exceeded by new character if(valid) - *valid = TRUE; + *valid = true; return len; }