MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / SetCVarInt

Function SetCVarInt

Descent3/dedicated_server.cpp:405–520  ·  view source on GitHub ↗

Sets the value for a cvar INT type

Source from the content-addressed store, hash-verified

403
404// Sets the value for a cvar INT type
405void SetCVarInt(int index, int val) {
406 void *dest_variable;
407
408 if (CVars[index].type != CVAR_TYPE_INT)
409 return; // Only handles ints
410
411 dest_variable = CVars[index].dest_variable;
412
413 if (!(CVars[index].var_min == -1 && CVars[index].var_max == -1)) {
414 if (val < CVars[index].var_min)
415 val = (int)CVars[index].var_min;
416
417 if (val > CVars[index].var_max)
418 val = (int)CVars[index].var_max;
419 }
420
421 // Do command specific stuff here
422 switch (index) {
423 case CVAR_TIMELIMIT: {
424 if (val > 0)
425 Netgame.flags |= NF_TIMER;
426 else
427 Netgame.flags &= ~NF_TIMER;
428 } break;
429
430 case CVAR_KILLGOAL: {
431 if (val > 0)
432 Netgame.flags |= NF_KILLGOAL;
433 else
434 Netgame.flags &= ~NF_KILLGOAL;
435 } break;
436
437 case CVAR_MAXPLAYERS: {
438 if (val > MAX_PLAYERS)
439 val = MAX_PLAYERS;
440 else if (val < 2)
441 val = 2;
442
443 } break;
444
445 case CVAR_BRIGHTPLAYERS: {
446 if (val)
447 Netgame.flags |= NF_BRIGHT_PLAYERS;
448 else
449 Netgame.flags &= ~NF_BRIGHT_PLAYERS;
450 } break;
451
452 case CVAR_USESMOOTHING: {
453 if (val)
454 Netgame.flags |= NF_USE_SMOOTHING;
455 else
456 Netgame.flags &= ~NF_USE_SMOOTHING;
457 } break;
458
459 case CVAR_PEER2PEER: {
460 if (val) {
461 Netgame.flags |= NF_PEER_PEER;
462 Netgame.flags &= ~NF_PERMISSABLE;

Callers 1

SetCVarFunction · 0.85

Calls 1

MultiEndLevelFunction · 0.85

Tested by

no test coverage detected