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

Function SetCVar

Descent3/dedicated_server.cpp:609–658  ·  view source on GitHub ↗

The accessor function that sets the value of a cvar

Source from the content-addressed store, hash-verified

607
608// The accessor function that sets the value of a cvar
609void SetCVar(const char *cvar_string, const char *cvar_argument, bool game_init) {
610 int i;
611 int done = 0;
612
613 for (i = 0; i < MAX_CVARS && !done; i++) {
614 if (!(stricmp(cvar_string, CVars[i].varname))) {
615 done = 1;
616
617 if (game_init) {
618 if (!(CVars[i].permissions & CVAR_GAMEINIT)) {
619 PrintDedicatedMessage(TXT_DS_CANTUSEINIT);
620 PrintDedicatedMessage("\n");
621 continue;
622 }
623
624 } else {
625 if (!(CVars[i].permissions & CVAR_GAMEPLAY)) {
626 PrintDedicatedMessage(TXT_DS_CANTUSEPLAY);
627 PrintDedicatedMessage("\n");
628 continue;
629 }
630 }
631
632 if (CVars[i].type != CVAR_TYPE_NONE && i != CVAR_MESSAGE) {
633 PrintDedicatedMessage(TXT_DS_VARSET, cvar_string, cvar_argument);
634 PrintDedicatedMessage("\n");
635 }
636
637 switch (CVars[i].type) {
638 case CVAR_TYPE_INT: {
639 int val = atoi(cvar_argument);
640 SetCVarInt(i, val);
641 } break;
642 case CVAR_TYPE_NONE: {
643 SetCVarNone(i);
644 } break;
645 case CVAR_TYPE_FLOAT: {
646 float val = (float)atof(cvar_argument);
647 SetCVarFloat(i, val);
648 } break;
649 case CVAR_TYPE_STRING: {
650 SetCVarString(i, cvar_argument);
651 } break;
652 default:
653 Int3(); // Get Jason, no cvar argument defined
654 break;
655 }
656 }
657 }
658}
659
660// The accessor function that sets the value of a cvar...INT only
661void SetCVar(const char *cvar_string, int cvar_argument) {

Callers 3

LoadServerConfigFileFunction · 0.85
DoDedicatedServerFrameFunction · 0.85
DedicatedReadTelnetFunction · 0.85

Calls 5

PrintDedicatedMessageFunction · 0.85
SetCVarIntFunction · 0.85
SetCVarNoneFunction · 0.85
SetCVarFloatFunction · 0.85
SetCVarStringFunction · 0.85

Tested by

no test coverage detected