X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Futil.qc;h=d668a384c30984c3c2038579e8944428778e8a31;hb=53c9348aa146e7da4c06c0199d2955cd7d1d433b;hp=15863f369f4d0da86e849d93d5ee0b77b609fde8;hpb=bf20397b0c62c9de0335ef9d70d60842fde9d0b2;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 15863f369..d668a384c 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -408,6 +408,22 @@ 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; @@ -874,7 +890,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; } @@ -911,7 +927,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; @@ -2559,7 +2575,6 @@ void FindConnectedComponent(entity e, .entity fld, findNextEntityNearFunction_t } // todo: this sucks, lets find a better way to do backtraces? -#ifndef MENUQC void backtrace(string msg) { float dev, war; @@ -2581,7 +2596,6 @@ void backtrace(string msg) cvar_set("developer", ftos(dev)); cvar_set("prvm_backtraceforwarnings", ftos(war)); } -#endif // color code replace, place inside of sprintf and parse the string string CCR(string input) @@ -2752,3 +2766,40 @@ 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