]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/util.qh
Merge remote-tracking branch 'origin/master' into samual/combined_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util.qh
index a5ef7b3afc06026707fa60845cafc688a6f1fe6e..682c86a04952dcb66931c85cc38009ecdb0acdd8 100644 (file)
@@ -52,7 +52,7 @@ void ACCUMULATE_call(string func)
 // used for simplifying ACCUMULATE_FUNCTIONs
 #define SET_FIRST_OR_LAST(input,first,count) if(!input) { input = (first + count); }
 #define SET_FIELD_COUNT(field,first,count) if(!field) { field = (first + count); ++count; }
-#define CHECK_MAX_COUNT(name,max,count,type) if(count == max) { error(strcat("Maximum ", type, " hit: ", #name, ": ", ftos(count), ".\n")); }
+#define CHECK_MAX_COUNT(name,max,count,type) if(count > max) { error(strcat("Maximum ", type, " hit: ", #name, ": ", ftos(count), ".\n")); }
 
 // this returns a tempstring containing a copy of s with additional \n newlines added, it also replaces \n in the text with a real newline
 // NOTE: s IS allowed to be a tempstring
@@ -101,10 +101,11 @@ void buf_save(float buf, string filename);
 
 // modulo function
 #ifndef MENUQC
-float mod(float a, float b) { return a - (floor(a / b) * b); }   
+float mod(float a, float b) { return a - (floor(a / b) * b); }
 #endif
 
 #define TIME_TO_NTHS(t,n) floor((t) * (n) + 0.4)
+string format_time(float seconds);
 string mmsss(float t);
 string mmssss(float t);
 
@@ -367,9 +368,15 @@ void FindConnectedComponent(entity e, .entity fld, findNextEntityNearFunction_t
 // expand multiple arguments into one argument by stripping parenthesis
 #define XPD(...) __VA_ARGS__
 
-#ifndef MENUQC
+// Some common varargs functions. Lowercase as they match C.
+#define printf(...) print(sprintf(__VA_ARGS__))
+#define dprintf(...) dprint(sprintf(__VA_ARGS__))
+#define fprintf(file, ...) fputs(file, sprintf(__VA_ARGS__))
+#define bprintf(...) bprint(sprintf(__VA_ARGS__))
+
+//#ifndef MENUQC
 void backtrace(string msg);
-#endif
+//#endif
 
 // color code replace, place inside of sprintf and parse the string... defaults described as constants
 // foreground/normal colors