X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fnet_notice.qc;h=1d10cf94fb8249a9fbaef77fb57e8c25feb004f4;hp=59061e5a97c99b257e879ccdd5084bcc7c1521ca;hb=991de5e6922cd3c283de56c3249624f0f1bfe767;hpb=7bcb3a89b3271e018da4d92437dc5ba125ea8698 diff --git a/qcsrc/common/net_notice.qc b/qcsrc/common/net_notice.qc index 59061e5a9..1d10cf94f 100644 --- a/qcsrc/common/net_notice.qc +++ b/qcsrc/common/net_notice.qc @@ -3,9 +3,8 @@ REGISTER_NET_TEMP(TE_CSQC_SVNOTICE) #ifdef SVQC -void sv_notice_join_think() +void sv_notice_join_think(entity this) { - SELFPARAM(); int argc = tokenizebyseparator(autocvar_sv_join_notices, "|"); if (argc <= 0) return; for (int i = 0; i < argc; ++i) @@ -30,7 +29,7 @@ void sv_notice_to(entity _to, string _notice, float _howlong, float _modal) void sv_notice_toall(string _notice, float _howlong, float _modal) { - FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(sv_notice_to(it, _notice, _howlong, _modal))); + FOREACH_CLIENT(IS_REAL_CLIENT(it), sv_notice_to(it, _notice, _howlong, _modal)); } #endif // SVQC @@ -42,25 +41,30 @@ NET_HANDLE(TE_CSQC_SVNOTICE, bool isNew) return true; } entity cl_notices; -STATIC_INIT(cl_notice) -{ - cl_notices = LL_NEW(); -} void cl_notice_read() { - entity _notice = new(sv_notice); - make_pure(_notice); + entity _notice = new_pure(sv_notice); _notice.netname = strzone(ReadString()); _notice.alpha = ReadLong() + time; _notice.skin = ReadByte(); + if(!cl_notices) + cl_notices = LL_NEW(); LL_PUSH(cl_notices, _notice); } void cl_notice_run() { + if (!cl_notices) + return; + bool flag = false; - LL_EACH(cl_notices, it.alpha > time, LAMBDA(flag = true; break)); - if (!flag) return; + LL_EACH(cl_notices, it.alpha > time, { flag = true; break; }); + if (!flag) + { + LL_DELETE(cl_notices); + return; + } + const int M1 = 30; const int M2 = 10; @@ -76,13 +80,24 @@ void cl_notice_run() drawfill(v1, v2, '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL); vector v3 = v1 + '10 10 0'; - #define OUT(s, z) MACRO_BEGIN { drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3.y += z + 4; } MACRO_END + #define OUT(s, z) MACRO_BEGIN \ + drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); \ + v3.y += z + 4; \ + MACRO_END + float cur_time = 0; + float time_width = 48; OUT(_("^1Server notices:"), 32); - LL_EACH(cl_notices, it.alpha > time, LAMBDA( - string s = sprintf(_("^7%s (^3%d sec left)"), it.netname , rint(it.alpha - time)); - OUT(s, 16); - )); + LL_EACH(cl_notices, it.alpha > time, { + if(it.alpha - cur_time > 0.1) + { + cur_time = it.alpha; + string s = sprintf("^3%d", ceil(cur_time - time)); + drawcolorcodedstring(v3 + eX * 0.5 * (time_width - stringwidth(s, true, '1 1 0' * 16)), s, '1 1 0' * 16, 1, DRAWFLAG_NORMAL); + v3.x = v1.x + 10 + time_width; + } + OUT(it.netname, 16); + }); #undef OUT }