MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / Update

Method Update

neo/framework/CVarSystem.cpp:176–219  ·  view source on GitHub ↗

============ idInternalCVar::Update ============ */

Source from the content-addressed store, hash-verified

174============
175*/
176void idInternalCVar::Update( const idCVar *cvar ) {
177
178 // if this is a statically declared variable
179 if ( cvar->GetFlags() & CVAR_STATIC ) {
180
181 if ( flags & CVAR_STATIC ) {
182
183 // the code has more than one static declaration of the same variable, make sure they have the same properties
184 if ( resetString.Icmp( cvar->GetString() ) != 0 ) {
185 common->Warning( "CVar '%s' declared multiple times with different initial value", nameString.c_str() );
186 }
187 if ( ( flags & (CVAR_BOOL|CVAR_INTEGER|CVAR_FLOAT) ) != ( cvar->GetFlags() & (CVAR_BOOL|CVAR_INTEGER|CVAR_FLOAT) ) ) {
188 common->Warning( "CVar '%s' declared multiple times with different type", nameString.c_str() );
189 }
190 if ( valueMin != cvar->GetMinValue() || valueMax != cvar->GetMaxValue() ) {
191 common->Warning( "CVar '%s' declared multiple times with different minimum/maximum", nameString.c_str() );
192 }
193
194 }
195
196 // the code is now specifying a variable that the user already set a value for, take the new value as the reset value
197 resetString = cvar->GetString();
198 descriptionString = cvar->GetDescription();
199 description = descriptionString.c_str();
200 valueMin = cvar->GetMinValue();
201 valueMax = cvar->GetMaxValue();
202 Mem_Free( valueStrings );
203 valueStrings = CopyValueStrings( cvar->GetValueStrings() );
204 valueCompletion = cvar->GetValueCompletion();
205 UpdateValue();
206 cvarSystem->SetModifiedFlags( cvar->GetFlags() );
207 }
208
209 flags |= cvar->GetFlags();
210
211 UpdateCheat();
212
213 // only allow one non-empty reset string without a warning
214 if ( resetString.Length() == 0 ) {
215 resetString = cvar->GetString();
216 } else if ( cvar->GetString()[0] && resetString.Cmp( cvar->GetString() ) != 0 ) {
217 common->Warning( "cvar \"%s\" given initial values: \"%s\" and \"%s\"\n", nameString.c_str(), resetString.c_str(), cvar->GetString() );
218 }
219}
220
221/*
222============

Callers 1

RegisterMethod · 0.45

Calls 14

Mem_FreeFunction · 0.85
GetMinValueMethod · 0.80
GetMaxValueMethod · 0.80
GetValueStringsMethod · 0.80
GetValueCompletionMethod · 0.80
SetModifiedFlagsMethod · 0.80
IcmpMethod · 0.60
GetFlagsMethod · 0.45
GetStringMethod · 0.45
WarningMethod · 0.45
c_strMethod · 0.45
GetDescriptionMethod · 0.45

Tested by

no test coverage detected