X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Flib%2Fcounting.qh;h=303ee6988383d6f9cdfc9a23a561e9e44e0f1fe3;hb=95f519076e501b981eb877dd921dee635b2fbd77;hp=c084b5efe3a417b557202228d2b19ad98bf06a41;hpb=cbb0a16ac5554caedc4af3d81ff857c40eb9bdb9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/counting.qh b/qcsrc/lib/counting.qh index c084b5efe..303ee6988 100644 --- a/qcsrc/lib/counting.qh +++ b/qcsrc/lib/counting.qh @@ -117,10 +117,10 @@ string count_fill(float interval, string zeroth, string first, string second, st } ERASEABLE -string process_time(float outputtype, float seconds) +string process_time(float outputtype, int seconds) { - float tmp_hours = 0, tmp_minutes = 0, tmp_seconds = 0; - float tmp_years = 0, tmp_weeks = 0, tmp_days = 0; + int tmp_hours = 0, tmp_minutes = 0, tmp_seconds = 0; + int tmp_years = 0, tmp_weeks = 0, tmp_days = 0; tmp_seconds = floor(seconds); @@ -159,44 +159,17 @@ string process_time(float outputtype, float seconds) case 2: { string output = ""; - - output = count_seconds(tmp_seconds); - - if (tmp_minutes) - { - output = strcat( - count_minutes(tmp_minutes), - ((output != "") ? strcat(", ", output) : "")); - } - - if (tmp_hours) - { - output = strcat( - count_hours(tmp_hours), - ((output != "") ? strcat(", ", output) : "")); - } - - if (tmp_days) - { - output = strcat( - count_days(tmp_days), - ((output != "") ? strcat(", ", output) : "")); - } - - if (tmp_weeks) - { - output = strcat( - count_weeks(tmp_weeks), - ((output != "") ? strcat(", ", output) : "")); - } - - if (tmp_years) - { - output = strcat( - count_years(tmp_years), - ((output != "") ? strcat(", ", output) : "")); - } - + #define APPEND_TIME(unit) \ + if (tmp_##unit) output = strcat(output, ((output != "") ? ", " : ""), count_##unit(tmp_##unit)) + APPEND_TIME(years); + APPEND_TIME(weeks); + APPEND_TIME(days); + APPEND_TIME(hours); + APPEND_TIME(minutes); + APPEND_TIME(seconds); + #undef APPEND_TIME + if (output == "") + return count_seconds(0); return output; } case 3: