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

Function MultiLoadSettings

Descent3/multi_save_setting.cpp:140–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140int MultiLoadSettings(const char *filename) {
141 CFILE *cf;
142 char szinput[MAX_MPS_LINE_LEN];
143 char *toklabel, *tokval;
144 char seps[] = "\t ";
145 int objid;
146 cf = cfopen(filename, "rt");
147 if (!cf)
148 return 0;
149
150 while (cf_ReadString(szinput, MAX_MPS_LINE_LEN - 1, cf)) {
151
152 toklabel = strtok(szinput, seps);
153 tokval = strtok(NULL, seps);
154 if (!tokval) {
155 continue;
156 }
157 if (stricmp(toklabel, "NAME") == 0) {
158 strcpy(Netgame.name, tokval);
159 // Do this so the name can still have spaces
160 tokval = strtok(NULL, seps);
161 while (tokval) {
162 strcat(Netgame.name, " ");
163 strcat(Netgame.name, tokval);
164 tokval = strtok(NULL, seps);
165 }
166 } else if (stricmp(toklabel, "MISSION") == 0) {
167 strcpy(Netgame.mission, tokval);
168 // Do this so the mission can still have spaces
169 tokval = strtok(NULL, seps);
170 while (tokval) {
171 strcat(Netgame.mission, " ");
172 strcat(Netgame.mission, tokval);
173 tokval = strtok(NULL, seps);
174 }
175 } else if (stricmp(toklabel, "SCRIPT") == 0) {
176 strcpy(Netgame.scriptname, tokval);
177 // Do this so the script can still have spaces
178 tokval = strtok(NULL, seps);
179 while (tokval) {
180 strcat(Netgame.scriptname, " ");
181 strcat(Netgame.scriptname, tokval);
182 tokval = strtok(NULL, seps);
183 }
184 } else if (stricmp(toklabel, "PPS") == 0) {
185 Netgame.packets_per_second = atoi(tokval);
186 } else if (stricmp(toklabel, "PEERPEER") == 0) {
187 if (stricmp(tokval, "true") == 0)
188 Netgame.flags |= NF_PEER_PEER;
189 else
190 Netgame.flags &= ~NF_PEER_PEER;
191 } else if (stricmp(toklabel, "PERMISSABLE") == 0) {
192 if (stricmp(tokval, "true") == 0)
193 Netgame.flags |= NF_PERMISSABLE;
194 else
195 Netgame.flags &= ~NF_PERMISSABLE;
196 } else if (stricmp(toklabel, "RANDOMIZERESPAWN") == 0) {
197 if (stricmp(tokval, "true") == 0)

Callers 2

MultiDoConfigLoadFunction · 0.85
SetCVarStringFunction · 0.85

Calls 4

cfopenFunction · 0.85
cf_ReadStringFunction · 0.85
FindObjectIDNameFunction · 0.85
PlayerSetShipPermissionFunction · 0.85

Tested by

no test coverage detected