1 void forAllDescendants(entity root, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
3 depthfirst(root, parent, firstChild, nextSibling, funcPre, funcPost, pass);
7 void SUB_Null_ee(entity e1, entity e2)
10 void saveCvarsOf(entity ignore, entity e)
15 void loadCvarsOf(entity ignore, entity e)
20 void saveAllCvars(entity root)
22 forAllDescendants(root, saveCvarsOf, SUB_Null_ee, NULL);
24 void loadAllCvars(entity root)
26 forAllDescendants(root, loadCvarsOf, SUB_Null_ee, NULL);
30 void saveCvarsMulti(entity me)
34 n = tokenize(me.cvarNames);
36 cvar_set(me.cvarName, s);
37 for(i = 0; i < n; ++i)
41 .void(entity) draw_setDependent;
42 .string cvar_setDependent;
43 .float cvarMin_setDependent;
44 .float cvarMax_setDependent;
45 .string cvar2_setDependent;
46 .float cvar2Min_setDependent;
47 .float cvar2Max_setDependent;
48 .float op_setDependent;
49 .string cvarString_setDependent;
50 .string cvarValue_setDependent;
51 void setDependent_Check(entity e)
55 if(e.cvarString_setDependent)
57 s = cvar_string(e.cvarString_setDependent);
58 e.disabled = (cvar_string(e.cvarString_setDependent) == e.cvarValue_setDependent);
62 if(e.cvar_setDependent)
64 f = cvar(e.cvar_setDependent);
65 if(e.cvarMin_setDependent <= e.cvarMax_setDependent)
66 e.disabled = ((f < e.cvarMin_setDependent) || (f > e.cvarMax_setDependent));
68 e.disabled = ((f >= e.cvarMax_setDependent) && (f <= e.cvarMin_setDependent));
70 if(e.cvar2_setDependent)
72 f = cvar(e.cvar2_setDependent);
73 if(e.cvar2Min_setDependent <= e.cvar2Max_setDependent)
74 e.disabled = (e.disabled + ((f < e.cvar2Min_setDependent) || (f > e.cvar2Max_setDependent)) > e.op_setDependent);
76 e.disabled = (e.disabled + ((f >= e.cvar2Max_setDependent) && (f <= e.cvar2Min_setDependent)) > e.op_setDependent);
80 void setDependent_Draw(entity e)
82 setDependent_Check(e);
83 e.draw_setDependent(e);
85 void setDependent(entity e, string theCvarName, float theCvarMin, float theCvarMax)
87 e.draw_setDependent = e.draw;
88 e.cvar_setDependent = theCvarName;
89 e.cvarMin_setDependent = theCvarMin;
90 e.cvarMax_setDependent = theCvarMax;
91 e.cvar2_setDependent = string_null;
92 e.draw = setDependent_Draw;
93 setDependent_Check(e);
95 void setDependentStringNotEqual(entity e, string theCvarName, string theCvarValue)
97 e.draw_setDependent = e.draw;
98 e.cvarString_setDependent = theCvarName;
99 e.cvarValue_setDependent = theCvarValue;
100 e.cvar_setDependent = string_null;
101 e.cvar2_setDependent = string_null;
102 e.draw = setDependent_Draw;
103 setDependent_Check(e);
105 void setDependentAND(entity e, string theCvarName, float theCvarMin, float theCvarMax, string theCvar2Name, float theCvar2Min, float theCvar2Max)
107 e.draw_setDependent = e.draw;
108 e.cvar_setDependent = theCvarName;
109 e.cvarMin_setDependent = theCvarMin;
110 e.cvarMax_setDependent = theCvarMax;
111 e.cvar2_setDependent = theCvar2Name;
112 e.cvar2Min_setDependent = theCvar2Min;
113 e.cvar2Max_setDependent = theCvar2Max;
114 e.op_setDependent = 0;
115 e.draw = setDependent_Draw;
116 setDependent_Check(e);
118 void setDependentOR(entity e, string theCvarName, float theCvarMin, float theCvarMax, string theCvar2Name, float theCvar2Min, float theCvar2Max)
120 e.draw_setDependent = e.draw;
121 e.cvar_setDependent = theCvarName;
122 e.cvarMin_setDependent = theCvarMin;
123 e.cvarMax_setDependent = theCvarMax;
124 e.cvar2_setDependent = theCvar2Name;
125 e.cvar2Min_setDependent = theCvar2Min;
126 e.cvar2Max_setDependent = theCvar2Max;
127 e.op_setDependent = 1;
128 e.draw = setDependent_Draw;
129 setDependent_Check(e);
132 // EXTRESPONSE SYSTEM ////////////////////////////////////////////////////////
134 float _Nex_ExtResponseSystem_RequestsSent;
135 float _Nex_ExtResponseSystem_VersionHandled;
136 string _Nex_ExtResponseSystem_UpdateTo;
137 float _Nex_ExtResponseSystem_RetryTime;
138 float _Nex_ExtResponseSystem_RetryTime_LastDelay;
140 void() Item_Nex_ExtResponseSystem_SendQuery =
142 dprint("Sending extended response requests...\n");
143 localcmd(strcat("packet update.alientrap.org:27950 \"getExtResponse checkUpdates nexuiz ", cvar_string("g_nexuizversion"), "\"\n"));
144 _Nex_ExtResponseSystem_RequestsSent = TRUE;
145 _Nex_ExtResponseSystem_RetryTime_LastDelay = _Nex_ExtResponseSystem_RetryTime_LastDelay * 2 + 1;
146 _Nex_ExtResponseSystem_RetryTime = time + _Nex_ExtResponseSystem_RetryTime_LastDelay;
149 void(float argc) Item_Nex_ExtResponseSystem_Parse =
151 dprint("Received extended response packet from ", argv(0), "\n");
152 if(!_Nex_ExtResponseSystem_RequestsSent)
154 dprint(" But I haven't sent a request yet! Ignoring.\n");
157 if(argv(1) == "noUpdateAvailable")
159 if(_Nex_ExtResponseSystem_VersionHandled)
161 dprint(" duplicated update notice, ignored\n");
164 _Nex_ExtResponseSystem_VersionHandled = 1;
166 else if(argv(1) == "updateAvailable")
168 if(_Nex_ExtResponseSystem_VersionHandled)
170 dprint(" duplicated update notice, ignored\n");
173 _Nex_ExtResponseSystem_VersionHandled = 1;
174 _Nex_ExtResponseSystem_UpdateTo = strzone(argv(2)); // note: only one packet can be handled, so this can't be a leak
177 dprint(" UNKNOWN RESPONSE TYPE: ", argv(1), "\n");
180 void() Item_Nex_ExtResponseSystem_CheckForResponse =
184 while(strlen((s = getextresponse())))
187 Item_Nex_ExtResponseSystem_Parse(argc);
191 // END OF EXTRESPONSE SYSTEM /////////////////////////////////////////////////
198 MapInfo_Cache_Create();
200 if(!MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 1))
204 sz = eX * 0.025 + eY * 0.025 * (draw_scale_x / draw_scale_y);
205 draw_CenterText('0.5 0.5 0' - 1.25 * sz_y * eY, "Autogenerating mapinfo for newly added maps...", sz, '1 1 1', 1, 0);
207 boxA = '0.05 0.5 0' + 0.25 * sz_y * eY;
208 boxB = '0.95 0.5 0' + 1.25 * sz_y * eY;
209 draw_Fill(boxA, boxB - boxA, '1 1 1', 1);
213 draw_Fill(boxA, boxB - boxA, '0.1 0.1 0.1', 1);
215 boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress;
216 draw_Fill(boxA, boxB - boxA, '0 0 1', 1);
223 string campaign_name_previous;
224 float campaign_won_previous;
230 vector fs, sz, line, mid;
231 Item_Nex_ExtResponseSystem_CheckForResponse();
232 if(!_Nex_ExtResponseSystem_VersionHandled)
233 if(time > _Nex_ExtResponseSystem_RetryTime)
234 Item_Nex_ExtResponseSystem_SendQuery();
236 if(_Nex_ExtResponseSystem_UpdateTo != "")
238 fs = ((1/draw_scale_x) * eX + (1/draw_scale_y) * eY) * 12;
240 sz_x = draw_TextWidth(" http://www.nexuiz.com/ ", 0) * fs_x;
243 draw_alpha = sin(time * 0.112 - 0.3) * 0.7;
244 mid = eX * (0.5 + 0.5 * (1 - sz_x) * cos(time * 0.071))
245 + eY * (0.5 + 0.5 * (1 - sz_y) * sin(time * 0.071));
247 draw_Fill(mid - 0.5 * sz, sz, '1 1 0', 1);
248 draw_CenterText(mid - 1 * line, strcat("Update to ", _Nex_ExtResponseSystem_UpdateTo, " now!"), fs, '1 0 0', 1, 0);
249 draw_CenterText(mid - 0 * line, "http://www.nexuiz.com/", fs, '0 0 1', 1, 0);
251 if not(campaign_name_previous)
252 campaign_name_previous = strzone(strcat(campaign_name, "x")); // force unequal
253 if(campaign_name == campaign_name_previous)
255 if(cvar(strcat("g_campaign", campaign_name, "_won")))
257 if(!campaign_won_previous)
260 DialogOpenButton_Click_withCoords(NULL, main.winnerDialog, '0 0 0', eX * conwidth + eY * conheight);
262 campaign_won_previous = 1;
265 campaign_won_previous = 0;
269 strunzone(campaign_name_previous);
270 campaign_name_previous = strzone(campaign_name);
271 campaign_won_previous = cvar(strcat("g_campaign", campaign_name, "_won"));