MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / updateVariable

Method updateVariable

src/game/DynamicColor.cpp:338–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336
337
338void DynamicColor::updateVariable() {
339 // setup the basics
340 varTransition = true;
341 varLastChange = BzTime::getTick();
342 varOldColor = color;
343 varOldStates = varNewStates;
344
345 std::string expr = BZDB.get(varName);
346
347 // parse the optional delay timing
348 std::string::size_type atpos = expr.find_first_of('@');
349 if (atpos == std::string::npos) {
350 varTimeTmp = varTime;
351 }
352 else {
353 char* end;
354 const char* start = expr.c_str() + atpos + 1;
355 varTimeTmp = (float)strtod(start, &end);
356 if ((end == start) || isnan(varTimeTmp)) {
357 varTimeTmp = varTime; // conversion failed or invalid number
358 }
359 expr.resize(atpos); // strip everything after '@'
360 }
361
362 // parse the new color
363 if (expr != "*") {
364 parseColorString(expr, varNewColor);
365 varNewStates = false;
366 }
367 else {
368 varNewStates = true;
369 }
370
371 DYNCOLORMGR.setActive(this);
372}
373
374
375void DynamicColor::update(double t) {

Callers 1

bzdbCallbackMethod · 0.80

Calls 6

parseColorStringFunction · 0.85
c_strMethod · 0.80
setActiveMethod · 0.80
isnanFunction · 0.50
getMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected