X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Futil.qh;h=ae378ddfd55cfc1420385f4fd88ef7f5319c3a41;hb=930dfc485a5de542601235edf603ec04e18f2d1b;hp=a5ef7b3afc06026707fa60845cafc688a6f1fe6e;hpb=410ff5f6cc4f7d5d8282ba9d93fe6a65d1c74489;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index a5ef7b3af..ae378ddfd 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -1,4 +1,3 @@ -#define WANT_CONST // commonly used, but better make them macros #define TRUE 1 #define FALSE 0 @@ -52,7 +51,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,7 +100,7 @@ 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) @@ -364,9 +363,20 @@ typedef entity(entity cur, entity near, entity pass) findNextEntityNearFunction_ typedef float(entity a, entity b, entity pass) isConnectedFunction_t; void FindConnectedComponent(entity e, .entity fld, findNextEntityNearFunction_t nxt, isConnectedFunction_t iscon, entity pass); +#ifdef SVQC +vector combine_to_vector(float x, float y, float z); +vector get_corner_position(entity box, float corner); +#endif + // expand multiple arguments into one argument by stripping parenthesis #define XPD(...) __VA_ARGS__ +// 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 @@ -430,3 +440,10 @@ void dedicated_print(string input); #define CNT_ROUNDSTART 6 float Announcer_PickNumber(float type, float num); #endif + +#ifndef MENUQC +float Mod_Q1BSP_SuperContentsFromNativeContents(float nativecontents); +float Mod_Q1BSP_NativeContentsFromSuperContents(float supercontents); +#endif + +#define APPEND_TO_STRING(list,sep,add) ((list) = (((list) != "") ? strcat(list, sep, add) : (add)))