]> icculus.org git repositories - divverent/nexuiz.git/blob - data/menuqc/control/data/cvar.qc
Now overtime also gets initiated by equal frags and reaching the fraglimit.
[divverent/nexuiz.git] / data / menuqc / control / data / cvar.qc
1 // DP/Nex Menu
2 // control/data/cvar.qc
3
4 /*
5 ===================
6 Item_Data_Cvar
7 ===================
8 */
9
10 void() Item_Data_Cvar_Sync =
11 {
12         String_EntitySet( self, _syncValue, cvar_string( self.cvarName ) );
13         String_EntitySet( self, value, self._syncValue );
14 };
15
16 void() Item_Data_Cvar_Send =
17 {
18         cvar_set( self.cvarName, self.value );
19         Item_Data_Cvar_Sync();
20 };
21
22 void() Item_Data_Cvar_Reset =
23 {
24         if( self.defValue ) {
25                 String_EntitySet( self, value, self.defValue );
26         } else {
27                 String_EntitySet( self, value, cvar_defstring( self.cvarName ) );
28         }
29         Item_Data_Cvar_Send();
30 };
31
32 void() Item_Data_Cvar_Test_Start =
33 {
34         cvar_set( self.cvarName, self.value );
35 };
36
37 void() Item_Data_Cvar_Test_End =
38 {
39         cvar_set( self.cvarName, self._syncValue );
40 };
41
42 void() Item_Data_Cvar_Save_ExecString = {
43         Data_ExecString = String_Append( Data_ExecString, strcat( "set \"", self.cvarName, "\" \"", self.value, "\"\n" ) );
44 };
45
46 void( float pEvent ) Item_Data_Cvar_DataEvent =
47 {
48         switch( pEvent ) {
49         case ITEM_DATA_SYNC:
50                 Item_Data_Cvar_Sync();
51                 break;
52         case ITEM_DATA_SEND:
53                 Item_Data_Cvar_Send();
54                 break;
55         case ITEM_DATA_RESET:
56                 Item_Data_Cvar_Reset();
57                 break;
58         case ITEM_DATA_TEST_START:
59                 Item_Data_Cvar_Test_Start();
60                 break;
61         case ITEM_DATA_TEST_END:
62                 Item_Data_Cvar_Test_End();
63                 break;
64         case ITEM_DATA_SAVE_EXECSTRING:
65                 Item_Data_Cvar_Save_ExecString();
66                 break;
67         }
68 };
69
70 void() Item_Data_Cvar_Destroy =
71 {
72         Item_Data_Destroy();
73         String_EntityFree( self, cvarName );
74 };
75
76 void() Item_Data_Cvar_Spawn =
77 {
78         String_EntityZone( self, cvarName );
79         Item_Data_Init();
80
81         self.flag = self.flag | FLAG_HIDDEN;
82
83         self._dataEvent = Item_Data_Cvar_DataEvent;
84         self._reinit = Item_Data_Cvar_Sync;
85         self._destroy = Item_Data_Cvar_Destroy;
86 };
87
88 /*
89 ===================
90 Item_Data_ServerCvar
91 ===================
92 */
93
94 void( string pValue ) Item_Data_ServerCvar_SendSyncCmd = {
95         cmd( self.syncCmd, " \"", pValue, "\"\n" );
96 };
97 //#define Item_Data_ServerCvar_SendSyncCmd(pValue) cmd( self.syncCmd, " \"", pValue, "\"\n" )
98
99 void() Item_Data_ServerCvar_Sync =
100 {
101         String_EntitySet( self, _syncValue, cvar_string( self.cvarName ) );
102         String_EntitySet( self, value, self._syncValue );
103 };
104
105 void() Item_Data_ServerCvar_Send =
106 {
107         Item_Data_ServerCvar_SendSyncCmd( self.value );
108         String_EntitySet( self, _syncValue, self.value );
109 };
110
111 void() Item_Data_ServerCvar_Reset =
112 {
113         if( self.defValue ) {
114                 String_EntitySet( self, value, self.defValue );
115         } else {
116                 String_EntitySet( self, value, cvar_defstring( self.cvarName ) );
117         }
118         Item_Data_Cvar_Send();
119 };
120
121 void() Item_Data_ServerCvar_Test_Start =
122 {
123         Item_Data_ServerCvar_SendSyncCmd( self.value );
124 };
125
126 void() Item_Data_ServerCvar_Test_End =
127 {
128         Item_Data_ServerCvar_SendSyncCmd( self._syncValue );
129 };
130
131 void() Item_Data_ServerCvar_Save_ExecString = {
132         Data_ExecString = String_Append( Data_ExecString, strcat( self.syncCmd, " \"", self.value, "\"\n" ) );
133 };
134
135 void( float pEvent ) Item_Data_ServerCvar_DataEvent =
136 {
137         switch( pEvent ) {
138         case ITEM_DATA_SYNC:
139                 Item_Data_ServerCvar_Sync();
140                 break;
141         case ITEM_DATA_SEND:
142                 Item_Data_ServerCvar_Send();
143                 break;
144         case ITEM_DATA_RESET:
145                 Item_Data_ServerCvar_Reset();
146                 break;
147         case ITEM_DATA_TEST_START:
148                 Item_Data_ServerCvar_Test_Start();
149                 break;
150         case ITEM_DATA_TEST_END:
151                 Item_Data_ServerCvar_Test_End();
152                 break;
153         case ITEM_DATA_SAVE_EXECSTRING:
154                 Item_Data_ServerCvar_Save_ExecString();
155                 break;
156         }
157 };
158
159 void() Item_Data_ServerCvar_Destroy = {
160         String_EntityFree( self, syncCmd );
161         Item_Data_Cvar_Destroy();
162 };
163
164 void() Item_Data_ServerCvar_Spawn = {
165         Item_Data_Cvar_Spawn();
166
167         String_EntityZone( self, syncCmd );
168
169         self._reinit = Item_Data_ServerCvar_Sync;
170         self._destroy = Item_Data_ServerCvar_Destroy;
171         self._dataEvent = Item_Data_ServerCvar_DataEvent;
172 };
173
174 /*
175 ===================
176 Item_Data_CvarCreateSave
177 ===================
178 */
179
180 void() Item_Data_CvarCreateSave_Spawn =
181 {
182         Item_Data_Cvar_Spawn();
183
184         registercvar( self.cvarName, self.defValue, CVAR_SAVE );
185 };