X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Futil.qh;h=ae378ddfd55cfc1420385f4fd88ef7f5319c3a41;hb=930dfc485a5de542601235edf603ec04e18f2d1b;hp=47865428c18f5a8869e295f42a0e99eebfda886f;hpb=a7794afc2db05650096d9c22e55cb1ca6d82aa9b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 47865428c..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 @@ -6,6 +5,12 @@ // a dummy macro that prevents the "hanging ;" warning #define ENDS_WITH_CURLY_BRACE +#ifdef GMQCC +# define ACCUMULATE_FUNCTION(func,otherfunc) \ + [[accumulate]] void func() { otherfunc(); } +# define CALL_ACCUMULATED_FUNCTION(func) \ + func() +#else #ifdef HAVE_YO_DAWG_CPP // TODO make ascii art pic of xzibit // YO DAWG! @@ -24,7 +29,7 @@ func() #else # define ACCUMULATE_FUNCTION(func,otherfunc) \ - .void _ACCUMULATE_##func##__##otherfunc; + .float _ACCUMULATE_##func##__##otherfunc void ACCUMULATE_call(string func) { float i; @@ -41,11 +46,12 @@ void ACCUMULATE_call(string func) # define CALL_ACCUMULATED_FUNCTION(func) \ ACCUMULATE_call(#func) #endif +#endif // 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 @@ -94,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) @@ -208,7 +214,7 @@ float compressShotOrigin(vector v); vector decompressShotOrigin(float f); #ifdef SVQC -string rankings_reply, ladder_reply, lsmaps_reply, maplist_reply; // cached replies +string rankings_reply, ladder_reply, lsmaps_reply, maplist_reply, monsterlist_reply; // cached replies string records_reply[10]; #endif @@ -220,8 +226,10 @@ string RandomSelection_chosen_string; void RandomSelection_Init(); void RandomSelection_Add(entity e, float f, string s, float weight, float priority); -vector healtharmor_maxdamage(float h, float a, float armorblock); // returns vector: maxdamage, armorideal, 1 if fully armored -vector healtharmor_applydamage(float a, float armorblock, float damage); // returns vector: take, save, 0 +#ifndef MENUQC +vector healtharmor_maxdamage(float h, float a, float armorblock, float deathtype); // returns vector: maxdamage, armorideal, 1 if fully armored +vector healtharmor_applydamage(float a, float armorblock, float deathtype, float damage); // returns vector: take, save, 0 +#endif string getcurrentmod(); @@ -355,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 @@ -421,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)))