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

Function SetCVarString

Descent3/dedicated_server.cpp:550–606  ·  view source on GitHub ↗

Sets the value for a cvar string type

Source from the content-addressed store, hash-verified

548}
549// Sets the value for a cvar string type
550void SetCVarString(int index, const char *val) {
551 void *dest_variable;
552
553 if (CVars[index].type != CVAR_TYPE_STRING)
554 return; // Only handles ints
555
556 if (index == CVAR_MESSAGE) {
557 // say the message to everyone
558 char str[255];
559
560 int to_whom;
561 const char *msg = GetMessageDestination(val, &to_whom);
562
563 if (to_whom != MULTI_SEND_MESSAGE_ALL)
564 val = msg;
565
566 std::snprintf(str, sizeof(str), TXT_HUDSAY, Players[Player_num].callsign, val);
567
568 MultiSendMessageFromServer(GR_RGB(0, 128, 255), str, to_whom);
569
570 return;
571 }
572
573 if (index == CVAR_SETTINGS) {
574 if (MultiLoadSettings(val)) {
575 PrintDedicatedMessage(TXT_DS_SETTINGSLOADED);
576 PrintDedicatedMessage("\n");
577 } else {
578 PrintDedicatedMessage(TXT_DS_SETTINGSERR);
579 PrintDedicatedMessage("\n");
580 }
581 }
582
583 if (index == CVAR_DISALLOW) {
584 int objid = FindObjectIDName(IGNORE_TABLE(val));
585 if (objid != -1) {
586 PrintDedicatedMessage(TXT_DS_DISALLOWOBJECT, Object_info[objid].name);
587 PrintDedicatedMessage("\n");
588 Object_info[objid].multi_allowed = 0;
589 }
590 }
591
592 if (index == CVAR_ALLOW) {
593 int objid = FindObjectIDName(IGNORE_TABLE(val));
594 if (objid != -1) {
595 PrintDedicatedMessage(TXT_DS_ALLOWOBJECTS, Object_info[objid].name);
596 PrintDedicatedMessage("\n");
597 Object_info[objid].multi_allowed = 1;
598 }
599 }
600
601 dest_variable = CVars[index].dest_variable;
602
603 if (dest_variable) {
604 strncpy((char *)dest_variable, val, CVars[index].var_max);
605 }
606}
607

Callers 1

SetCVarFunction · 0.85

Calls 6

GetMessageDestinationFunction · 0.85
MultiLoadSettingsFunction · 0.85
PrintDedicatedMessageFunction · 0.85
FindObjectIDNameFunction · 0.85
GR_RGBFunction · 0.50

Tested by

no test coverage detected