X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Futil.qc;h=15cde708ab84978e148be46ae7abf388c7ea33b7;hp=dcf1142c45c729c04cec476dd8dcf90097e9f799;hb=dc891780036706390bcaa27975dcb71e499deeae;hpb=c4a2201788e1f5b0d3628f7964716f2690cd6cd0 diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index dcf1142c4..15cde708a 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -408,22 +408,6 @@ void buf_save(float buf, string pFilename) fclose(fh); } -string format_time(float seconds) -{ - float days, hours, minutes; - seconds = floor(seconds + 0.5); - days = floor(seconds / 864000); - seconds -= days * 864000; - hours = floor(seconds / 36000); - seconds -= hours * 36000; - minutes = floor(seconds / 600); - seconds -= minutes * 600; - if (days > 0) - return sprintf(_("%d days, %02d:%02d:%02d"), days, hours, minutes, seconds); - else - return sprintf(_("%02d:%02d:%02d"), hours, minutes, seconds); -} - string mmsss(float tenths) { float minutes; @@ -890,7 +874,7 @@ float cvar_settemp(string tmp_cvar, string tmp_value) if(!cvar_type(tmp_cvar)) { - print(sprintf("Error: cvar %s doesn't exist!\n", tmp_cvar)); + printf("Error: cvar %s doesn't exist!\n", tmp_cvar); return 0; } @@ -927,7 +911,7 @@ float cvar_settemp_restore() ++i; } else - print(sprintf("Error: cvar %s doesn't exist anymore! It can still be restored once it's manually recreated.\n", e.netname)); + printf("Error: cvar %s doesn't exist anymore! It can still be restored once it's manually recreated.\n", e.netname); } return i; @@ -1328,7 +1312,7 @@ string find_last_color_code(string s) ++carets; // check if carets aren't all escaped - if (carets == 1 || mod(carets, 2) == 1) // first check is just an optimization + if (carets & 1) { if(i+1 <= len) if(strstrofs("0123456789", substring(s, i+1, 1), 0) >= 0) @@ -2122,6 +2106,8 @@ float get_model_parameters(string m, float sk) get_model_parameters_weight = stof(s); if(c == "age") get_model_parameters_age = stof(s); + if(c == "description") + get_model_parameters_description = s; if(c == "bone_upperbody") get_model_parameters_bone_upperbody = s; if(c == "bone_weapon") @@ -2574,6 +2560,30 @@ void FindConnectedComponent(entity e, .entity fld, findNextEntityNearFunction_t queue_start.FindConnectedComponent_processing = 0; } +#ifdef SVQC +vector combine_to_vector(float x, float y, float z) +{ + vector result; result_x = x; result_y = y; result_z = z; + return result; +} + +vector get_corner_position(entity box, float corner) +{ + switch(corner) + { + case 1: return combine_to_vector(box.absmin_x, box.absmin_y, box.absmin_z); + case 2: return combine_to_vector(box.absmax_x, box.absmin_y, box.absmin_z); + case 3: return combine_to_vector(box.absmin_x, box.absmax_y, box.absmin_z); + case 4: return combine_to_vector(box.absmin_x, box.absmin_y, box.absmax_z); + case 5: return combine_to_vector(box.absmax_x, box.absmax_y, box.absmin_z); + case 6: return combine_to_vector(box.absmin_x, box.absmax_y, box.absmax_z); + case 7: return combine_to_vector(box.absmax_x, box.absmin_y, box.absmax_z); + case 8: return combine_to_vector(box.absmax_x, box.absmax_y, box.absmax_z); + default: return '0 0 0'; + } +} +#endif + // todo: this sucks, lets find a better way to do backtraces? #ifndef MENUQC void backtrace(string msg) @@ -2768,3 +2778,55 @@ float Announcer_PickNumber(float type, float num) return NOTIF_ABORT; // abort sending if none of these numbers were right } #endif + +#ifndef MENUQC +float Mod_Q1BSP_SuperContentsFromNativeContents(float nativecontents) +{ + switch(nativecontents) + { + case CONTENT_EMPTY: + return 0; + case CONTENT_SOLID: + return DPCONTENTS_SOLID | DPCONTENTS_OPAQUE; + case CONTENT_WATER: + return DPCONTENTS_WATER; + case CONTENT_SLIME: + return DPCONTENTS_SLIME; + case CONTENT_LAVA: + return DPCONTENTS_LAVA | DPCONTENTS_NODROP; + case CONTENT_SKY: + return DPCONTENTS_SKY | DPCONTENTS_NODROP | DPCONTENTS_OPAQUE; // to match behaviour of Q3 maps, let sky count as opaque + } + return 0; +} + +float Mod_Q1BSP_NativeContentsFromSuperContents(float supercontents) +{ + if(supercontents & (DPCONTENTS_SOLID | DPCONTENTS_BODY)) + return CONTENT_SOLID; + if(supercontents & DPCONTENTS_SKY) + return CONTENT_SKY; + if(supercontents & DPCONTENTS_LAVA) + return CONTENT_LAVA; + if(supercontents & DPCONTENTS_SLIME) + return CONTENT_SLIME; + if(supercontents & DPCONTENTS_WATER) + return CONTENT_WATER; + return CONTENT_EMPTY; +} +#endif + +vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t) +{ + return + (c - 2 * b + a) * (t * t) + + (b - a) * (2 * t) + + a; +} + +vector bezier_quadratic_getderivative(vector a, vector b, vector c, float t) +{ + return + (c - 2 * b + a) * (2 * t) + + (b - a) * 2; +}