]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/net_notice.qc
Merge branch 'master' into terencehill/ca_ft_fixes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / net_notice.qc
1 #ifdef SVQC
2 void sv_notice_join_think()
3 {
4     //NextLevel();
5     float argc = tokenizebyseparator(autocvar_sv_join_notices, "|");
6     if(argc > 0)
7     {
8         float i;
9         for(i = argc - 1; i >= 0; --i)
10             sv_notice_to(self.owner, argv(i), autocvar_sv_join_notices_time, FALSE);
11     }
12     remove(self);
13 }
14
15 void sv_notice_join()
16 {
17     // to-do: make sv_join_notices support per-entry times
18     if(autocvar_sv_join_notices == "")
19         return;
20
21     entity n = spawn();
22     n.owner = self;
23     n.think = sv_notice_join_think;
24     n.nextthink = time + 1;
25 }
26
27 void sv_notice_to(entity _to, string _notice, float _howlong, float _modal)
28 {
29         msg_entity = _to;
30         WriteByte(MSG_ONE, SVC_TEMPENTITY);
31         WriteByte(MSG_ONE, TE_CSQC_SVNOTICE);
32         WriteString(MSG_ONE, _notice);
33         WriteLong(MSG_ONE, _howlong);
34         WriteByte(MSG_ONE, _modal);
35 }
36
37 void sv_notice_toall(string _notice, float _howlong, float _modal)
38 {
39     entity _head;
40     FOR_EACH_REALCLIENT(_head)
41         sv_notice_to(_head, _notice, _howlong, _modal);
42
43 }
44
45 #endif // SVQC
46
47 #ifdef CSQC
48 void SUB_Remove()
49 { remove(self); }
50
51 void cl_notice_read()
52 {
53     entity _notice;
54     //float _done;
55     //float _modal;
56     _notice = spawn();
57     _notice.classname = "sv_notice";
58     _notice.netname = strzone(ReadString());
59     _notice.alpha = ReadLong() + time;
60     _notice.skin = ReadByte();
61 }
62
63 float cl_notice_run()
64 {
65     entity _notes;
66     string _notice;
67     float m = FALSE;
68
69     _notes = findchain(classname, "sv_notice");
70     if(!_notes)
71         return FALSE;
72     #define M1 30
73     #define M2 10
74
75     vector v1, v2 = '0 0 0', v3;
76     v1 = '1 1 0' * M1;
77     v2_x = vid_conwidth - (2 * M1);
78     v2_y = vid_conheight - (2 * M1);
79
80     drawfill(v1, v2, '0 0 0', 0.5, DRAWFLAG_NORMAL);
81     v1 = '1 1 0' * (M1 + M2);
82     v2_x = vid_conwidth - (2 * (M1 + M2));
83     v2_y = vid_conheight - (2 * (M1 + M2));
84     drawfill(v1, v2, '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
85     v3 = v1 + '10 10 0';
86
87     #define OUT(s,z) drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3_y += z + 4
88
89     OUT(_("^1Server notices:"), 32);
90
91     //drawcolorcodedstring(v1 + '5 5 0', "^1Server notices:", '32 32 0', 1, DRAWFLAG_NORMAL);
92     while(_notes)
93     {
94
95         _notice = sprintf(_("^7%s (^3%d sec left)"), _notes.netname , rint(_notes.alpha - time));
96         OUT(_notice, 16);
97
98         if(_notes.skin)
99             m = TRUE;
100
101         if(_notes.alpha <= time)
102         {
103             _notes.think = SUB_Remove;
104             _notes.nextthink = time;
105         }
106
107         _notes = _notes.chain;
108     }
109
110     #undef OUT
111     #undef M1
112     #undef M2
113
114     return m;
115 }
116
117 #endif // CSQC