feat(cvar): Unsigned integer type for cvars
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Ubuntu Cross to Win64 / Cross Compile with ming64 (1.4.0, ubuntu-latest) (push) Failing after 1m51s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Ubuntu Cross to Win64 / Cross Compile with ming64 (1.4.0, ubuntu-latest) (push) Failing after 1m51s
				
			This commit is contained in:
		
							parent
							
								
									beba96b915
								
							
						
					
					
						commit
						a79fd56051
					
				@ -102,6 +102,9 @@ RT_DLLEXPORT void rtNotifyCVARChange(const rt_cvar *cvar) {
 | 
			
		||||
    case RT_CVAR_TYPE_SIZE:
 | 
			
		||||
        rtLog("CVAR", "Changed %s to %zu.", cvar->name, cvar->sz);
 | 
			
		||||
        break;
 | 
			
		||||
    case RT_CVAR_TYPE_UINT:
 | 
			
		||||
        rtLog("CVAR", "Changed %s to %u.", cvar->name, cvar->ui);
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        rtLog("CVAR", "Changed %s, but the cvar has an invalid type.", cvar->name);
 | 
			
		||||
        break;
 | 
			
		||||
@ -299,6 +302,9 @@ RT_DLLEXPORT rt_result rtSetCVARFromString(rt_cvar *cvar, const char *value_str)
 | 
			
		||||
    case RT_CVAR_TYPE_SIZE:
 | 
			
		||||
        num_read = sscanf(value_str, "%zu", &cvar->sz);
 | 
			
		||||
        break;
 | 
			
		||||
    case RT_CVAR_TYPE_UINT:
 | 
			
		||||
        num_read = sscanf(value_str, "%u", &cvar->ui);
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        rtReportError("CVAR", "CVar %s has an invalid type.", cvar->name);
 | 
			
		||||
        return 0;
 | 
			
		||||
 | 
			
		||||
@ -13,6 +13,7 @@ typedef enum {
 | 
			
		||||
    RT_CVAR_TYPE_FLOAT,
 | 
			
		||||
    RT_CVAR_TYPE_STRING,
 | 
			
		||||
    RT_CVAR_TYPE_SIZE,
 | 
			
		||||
    RT_CVAR_TYPE_UINT,
 | 
			
		||||
} rt_cvar_type;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
@ -23,6 +24,7 @@ typedef struct {
 | 
			
		||||
        float f;
 | 
			
		||||
        const char *s;
 | 
			
		||||
        size_t sz;
 | 
			
		||||
        unsigned int ui;
 | 
			
		||||
    };
 | 
			
		||||
    rt_cvar_type type;
 | 
			
		||||
} rt_cvar;
 | 
			
		||||
@ -38,12 +40,14 @@ typedef void(rt_cvar_change_event_handler_fn)(rt_cvar *cvar, void *userdata);
 | 
			
		||||
    rt_cvar n = {.name = #n, .description = d, .s = (v), .type = RT_CVAR_TYPE_STRING}
 | 
			
		||||
#define RT_CVAR_SZ(n, d, v)                                                                        \
 | 
			
		||||
    rt_cvar n = {.name = #n, .description = d, .sz = (v), .type = RT_CVAR_TYPE_SIZE}
 | 
			
		||||
#define RT_CVAR_UI(n, d, v)                                                                        \
 | 
			
		||||
    rt_cvar n = {.name = #n, .description = d, .ui = (v), .type = RT_CVAR_TYPE_UINT}
 | 
			
		||||
 | 
			
		||||
RT_DLLEXPORT void rtRegisterCVAR(rt_cvar *cvar);
 | 
			
		||||
 | 
			
		||||
RT_DLLEXPORT rt_cvar *rtGetCVAR(const char *name);
 | 
			
		||||
 | 
			
		||||
/* Change event handlers are called when rtNotifyCVARChange is called. 
 | 
			
		||||
/* Change event handlers are called when rtNotifyCVARChange is called.
 | 
			
		||||
 * The system gives no guarantees about the order in which these are called.
 | 
			
		||||
 *
 | 
			
		||||
 * NOTE: A internal mutex is held while the event handlers run, which means that */
 | 
			
		||||
 | 
			
		||||
@ -75,6 +75,7 @@ enum {
 | 
			
		||||
    RT_SUCCESS       = 0,
 | 
			
		||||
    RT_OUT_OF_MEMORY = 1,
 | 
			
		||||
    RT_INVALID_VALUE = 2,
 | 
			
		||||
    RT_NOT_SUPPORTED = 3,
 | 
			
		||||
 | 
			
		||||
    RT_CUSTOM_ERROR_START,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user