2 // control/data/cvar.qc
10 void() Item_Data_Cvar_Sync =
12 String_EntitySet( self, _syncValue, cvar_string( self.cvarName ) );
13 String_EntitySet( self, value, self._syncValue );
16 void() Item_Data_Cvar_Send =
18 cvar_set( self.cvarName, self.value );
19 Item_Data_Cvar_Sync();
22 void() Item_Data_Cvar_Reset =
25 String_EntitySet( self, value, self.defValue );
27 String_EntitySet( self, value, cvar_defstring( self.cvarName ) );
29 Item_Data_Cvar_Send();
32 void() Item_Data_Cvar_Test_Start =
34 cvar_set( self.cvarName, self.value );
37 void() Item_Data_Cvar_Test_End =
39 cvar_set( self.cvarName, self._syncValue );
42 void() Item_Data_Cvar_Save_ExecString = {
43 Data_ExecString = String_Append( Data_ExecString, strcat( "set \"", self.cvarName, "\" \"", self.value, "\"\n" ) );
46 void( float pEvent ) Item_Data_Cvar_DataEvent =
50 Item_Data_Cvar_Sync();
53 Item_Data_Cvar_Send();
56 Item_Data_Cvar_Reset();
58 case ITEM_DATA_TEST_START:
59 Item_Data_Cvar_Test_Start();
61 case ITEM_DATA_TEST_END:
62 Item_Data_Cvar_Test_End();
64 case ITEM_DATA_SAVE_EXECSTRING:
65 Item_Data_Cvar_Save_ExecString();
70 void() Item_Data_Cvar_Destroy =
73 String_EntityFree( self, cvarName );
76 void() Item_Data_Cvar_Spawn =
78 String_EntityZone( self, cvarName );
81 self.flag = self.flag | FLAG_HIDDEN;
83 self._dataEvent = Item_Data_Cvar_DataEvent;
84 self._reinit = Item_Data_Cvar_Sync;
85 self._destroy = Item_Data_Cvar_Destroy;
94 void( string pValue ) Item_Data_ServerCvar_SendSyncCmd = {
95 cmd( self.syncCmd, " \"", pValue, "\"\n" );
97 //#define Item_Data_ServerCvar_SendSyncCmd(pValue) cmd( self.syncCmd, " \"", pValue, "\"\n" )
99 void() Item_Data_ServerCvar_Sync =
101 String_EntitySet( self, _syncValue, cvar_string( self.cvarName ) );
102 String_EntitySet( self, value, self._syncValue );
105 void() Item_Data_ServerCvar_Send =
107 Item_Data_ServerCvar_SendSyncCmd( self.value );
108 String_EntitySet( self, _syncValue, self.value );
111 void() Item_Data_ServerCvar_Reset =
113 if( self.defValue ) {
114 String_EntitySet( self, value, self.defValue );
116 String_EntitySet( self, value, cvar_defstring( self.cvarName ) );
118 Item_Data_Cvar_Send();
121 void() Item_Data_ServerCvar_Test_Start =
123 Item_Data_ServerCvar_SendSyncCmd( self.value );
126 void() Item_Data_ServerCvar_Test_End =
128 Item_Data_ServerCvar_SendSyncCmd( self._syncValue );
131 void() Item_Data_ServerCvar_Save_ExecString = {
132 Data_ExecString = String_Append( Data_ExecString, strcat( self.syncCmd, " \"", self.value, "\"\n" ) );
135 void( float pEvent ) Item_Data_ServerCvar_DataEvent =
139 Item_Data_ServerCvar_Sync();
142 Item_Data_ServerCvar_Send();
144 case ITEM_DATA_RESET:
145 Item_Data_ServerCvar_Reset();
147 case ITEM_DATA_TEST_START:
148 Item_Data_ServerCvar_Test_Start();
150 case ITEM_DATA_TEST_END:
151 Item_Data_ServerCvar_Test_End();
153 case ITEM_DATA_SAVE_EXECSTRING:
154 Item_Data_ServerCvar_Save_ExecString();
159 void() Item_Data_ServerCvar_Destroy = {
160 String_EntityFree( self, syncCmd );
161 Item_Data_Cvar_Destroy();
164 void() Item_Data_ServerCvar_Spawn = {
165 Item_Data_Cvar_Spawn();
167 String_EntityZone( self, syncCmd );
169 self._reinit = Item_Data_ServerCvar_Sync;
170 self._destroy = Item_Data_ServerCvar_Destroy;
171 self._dataEvent = Item_Data_ServerCvar_DataEvent;
176 Item_Data_CvarCreateSave
180 void() Item_Data_CvarCreateSave_Spawn =
182 Item_Data_Cvar_Spawn();
184 registercvar( self.cvarName, self.defValue, CVAR_SAVE );