]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Clean up qtypes.h. Use stdbool.h on non-MSVC. Replace allcaps with lowercase
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 26 May 2020 16:41:57 +0000 (16:41 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 26 May 2020 16:41:57 +0000 (16:41 +0000)
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

common.c
jpeg.c
libcurl.c
menu.c
prvm_cmds.c
prvm_edict.c
qtypes.h
sv_main.c
sv_phys.c
thread_win.c
utf8lib.c

index 4a05368b5b85d5e7a462cbe40cd823d5d569329a..090f097088e0a471390597b82cff9befd0bd3b6c 100644 (file)
--- 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 8eeb6d7b008fc41640ec3240c052abee0a8547af..effab6a1051dba3ee62f222eabbf1dca99cd5df4 100644 (file)
--- 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)
index 3d8de2b0ac158b871dbf43964d79ea2fa1f99ccc..b8f36dc24156731f44e9bde176e56848beb6c444 100644 (file)
--- 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 6092254778caf4b391aae2a353af076c5a7820c6..be6c3c01d3b844ba72fee795310f95137802b943 100644 (file)
--- 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);
 }
index 73d0a89a6ad8c1d22a9056df437debe32c15827c..ec68d188628c88dbd9fe8722c994ef2b8ef39859 100644 (file)
@@ -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);
        
 }
index a5a7b821f111aa16525708f4ea548a36da3cfe6e..9d81ef048263355bba93ed028b8e64e2bc358130 100644 (file)
@@ -2469,7 +2469,7 @@ fail:
                ;
        }
 
-       prog->loaded = TRUE;
+       prog->loaded = true;
 
        PRVM_UpdateBreakpoints(prog);
 
index f391a40af120ecfb27fc316759bded543c84fc85..d4fa148e189051342d9be25038f0494da16f6090 100644 (file)
--- 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 <stdbool.h>
 #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
 
index 3496bc2c98882227006170ced7a891a9721d9a2c..b10a67d9f13424b0119993cc0ddc28ac41ae1688 100644 (file)
--- 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
index 94587293cf4956671d6cc7b253460a6fe7908724..6d14da1deeb827a35dc18648b0716e0f311223d2 100644 (file)
--- 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;
index 8564ca195dd64fa416f4557efe3a871fe535c59e..ff1be87e8370b1c49501fc8e3c0e236aa468e22c 100644 (file)
@@ -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
index e552785d2a52376698b828d3ab7b0334aa197c0e..4099d0a762ece3f4f189f2f8cb6b882415271fe8 100644 (file)
--- 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;
                }