Debian Codegraph @

Descent3/multi_save_setting.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/multi_save_setting.cpp $
21 * $Revision: 12 $
22 * $Date: 5/05/00 9:04a $
23 * $Author: Matt $
24 *
25 * Multiplayer settings save/load
26 *
27 * $Log: /DescentIII/main/multi_save_setting.cpp $
28 *
29 * 12 5/05/00 9:04a Matt
30 * Allow ship names for the SHIPBAN command to have spaces, so the black
31 * pyro will work.
32 *
33 * 11 5/09/99 1:34p Kevin
34 * Added diffuculty level system to multiplayer
35 *
36 * 10 4/14/99 2:51a Jeff
37 * fixed some case mismatched #includes
38 *
39 * 9 3/25/99 3:29p Jason
40 * added option to randomize powerup respawn points
41 *
42 * 8 2/05/99 1:17p Jason
43 * added some options
44 *
45 * 7 12/07/98 12:54p Kevin
46 * Added Accurate weapon collisions flag
47 *
48 * 6 12/01/98 12:47p Jason
49 * got rid of NF_DROPMISORDERED and added NF_USE_SMOOTHING
50 *
51 * 5 10/17/98 2:32p Kevin
52 * FIxed problem with banned users getting stuck on the ban message
53 * screen.
54 *
55 * 4 10/02/98 10:11a Kevin
56 * dealt with spaces in the name of values
57 *
58 * 3 9/23/98 6:33p Kevin
59 * Fixed load settings
60 *
61 * 2 9/23/98 2:54p Kevin
62 * Saved multi config and changed UI to conform
63 *
64 * 1 9/23/98 10:15a Kevin
65 * Initial Version
66 *
67 * $NoKeywords: $
68 */
69
70 #include <stdio.h>
71 #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/
72 #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/
73 #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/
74 #include "ship.h"cxx . . $ `<file>/Descent3/ship.h`/
75 #include "multi_save_settings.h"cxx . . $ `<file>/Descent3/multi_save_settings.h`/
76
77 int MultiSaveSettingscxx . . $ MultiSaveSettings(5c4306d8553b3696).(const char *filename) {
78 CFILEcxx . . $ CFILE# *cf;
79 char szoutput[MAX_MPS_LINE_LENcxx . . $ `Descent3/multi_save_settings.h:46:9`!];
80 int i;
81 cf = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "wt");
82 if (!cf)
83 return 0;
84 snprintf(szoutput, sizeof(szoutput), "NAME\t%s", Netgamecxx . . $ Netgame..namecxx . . $ netgame_info#name.);
85 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
86 snprintf(szoutput, sizeof(szoutput), "MISSION\t%s", Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission.);
87 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
88 snprintf(szoutput, sizeof(szoutput), "SCRIPT\t%s", Netgamecxx . . $ Netgame..scriptnamecxx . . $ netgame_info#scriptname.);
89 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
90 snprintf(szoutput, sizeof(szoutput), "PPS\t%d", Netgamecxx . . $ Netgame..packets_per_secondcxx . . $ netgame_info#packets_per_second.);
91 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
92 snprintf(szoutput, sizeof(szoutput), "PEERPEER\t%s", (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!) ? "TRUE" : "FALSE");
93 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
94 snprintf(szoutput, sizeof(szoutput), "PERMISSABLE\t%s", (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!) ? "TRUE" : "FALSE");
95 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
96 snprintf(szoutput, sizeof(szoutput), "RANDOMIZERESPAWN\t%s",
97 (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_RANDOMIZE_RESPAWNcxx . . $ `Descent3/multi_external.h:241:9`!) ? "TRUE" : "FALSE");
98 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
99 snprintf(szoutput, sizeof(szoutput), "ROTVEL\t%s", (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_SENDROTVELcxx . . $ `Descent3/multi_external.h:231:9`!) ? "TRUE" : "FALSE");
100 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
101 snprintf(szoutput, sizeof(szoutput), "USESMOOTHING\t%s", (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_USE_SMOOTHINGcxx . . $ `Descent3/multi_external.h:237:9`!) ? "TRUE" : "FALSE");
102 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
103 snprintf(szoutput, sizeof(szoutput), "BRIGHTPLAYERS\t%s", (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_BRIGHT_PLAYERScxx . . $ `Descent3/multi_external.h:238:9`!) ? "TRUE" : "FALSE");
104 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
105 snprintf(szoutput, sizeof(szoutput), "MAXPLAYERS\t%d", Netgamecxx . . $ Netgame..max_playerscxx . . $ netgame_info#max_players.);
106 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
107 snprintf(szoutput, sizeof(szoutput), "RESPAWNTIME\t%d", Netgamecxx . . $ Netgame..respawn_timecxx . . $ netgame_info#respawn_time.);
108 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
109 snprintf(szoutput, sizeof(szoutput), "KILLGOAL\t%d", Netgamecxx . . $ Netgame..killgoalcxx . . $ netgame_info#killgoal.);
110 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
111 snprintf(szoutput, sizeof(szoutput), "TIMELIMIT\t%d", Netgamecxx . . $ Netgame..timelimitcxx . . $ netgame_info#timelimit.);
112 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
113 snprintf(szoutput, sizeof(szoutput), "ACCWEAP\t%s", (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_USE_ACC_WEAPcxx . . $ `Descent3/multi_external.h:236:9`!) ? "TRUE" : "FALSE");
114 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
115 snprintf(szoutput, sizeof(szoutput), "MLOOK\t%s", (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_ALLOW_MLOOKcxx . . $ `Descent3/multi_external.h:242:9`!) ? "TRUE" : "FALSE");
116 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
117 snprintf(szoutput, sizeof(szoutput), "DIFFICULTY\t%d", Netgamecxx . . $ Netgame..difficultycxx . . $ netgame_info#difficulty.);
118 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
119
120 for (i = 0; i < MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!; i++) {
121 if (Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`!) {
122 if (!Object_infocxx . . $ Object_info.[i].multi_allowedcxx . . $ object_info#multi_allowed.) {
123 snprintf(szoutput, sizeof(szoutput), "OBJBAN\t%s", Object_infocxx . . $ Object_info.[i].namecxx . . $ object_info#name.);
124 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
125 }
126 }
127 }
128 for (i = 0; i < MAX_SHIPScxx . . $ `Descent3/ship.h:122:9`!; i++) {
129 if (Shipscxx . . $ Ships.[i].usedcxx . . $ ship#used.) {
130 if (!PlayerIsShipAllowedcxx . . $ PlayerIsShipAllowed(cf9ef193275fa6d8).(0, i)) {
131 snprintf(szoutput, sizeof(szoutput), "SHIPBAN\t%s", Shipscxx . . $ Ships.[i].namecxx . . $ ship#name.);
132 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(cf, szoutput);
133 }
134 }
135 }
136 cfclosecxx . . $ cfclose(3639e799710acb68).(cf);
137 return 1;
138 }
139
140 int MultiLoadSettingscxx . . $ MultiLoadSettings(5c4306d8553b3696).(const char *filename) {
141 CFILEcxx . . $ CFILE# *cf;
142 char szinput[MAX_MPS_LINE_LENcxx . . $ `Descent3/multi_save_settings.h:46:9`!];
143 char *toklabel, *tokval;
144 char seps[] = "\t ";
145 int objid;
146 cf = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rt");
147 if (!cf)
148 return 0;
149
150 while (cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(szinput, MAX_MPS_LINE_LENcxx . . $ `Descent3/multi_save_settings.h:46:9`! - 1, cf)) {
151
152 toklabel = strtok(szinput, seps);
153 tokval = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, seps);
154 if (!tokval) {
155 continue;
156 }
157 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "NAME") == 0) {
158 strcpy(Netgamecxx . . $ Netgame..namecxx . . $ netgame_info#name., tokval);
159 // Do this so the name can still have spaces
160 tokval = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, seps);
161 while (tokval) {
162 strcat(Netgamecxx . . $ Netgame..namecxx . . $ netgame_info#name., " ");
163 strcat(Netgamecxx . . $ Netgame..namecxx . . $ netgame_info#name., tokval);
164 tokval = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, seps);
165 }
166 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "MISSION") == 0) {
167 strcpy(Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission., tokval);
168 // Do this so the mission can still have spaces
169 tokval = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, seps);
170 while (tokval) {
171 strcat(Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission., " ");
172 strcat(Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission., tokval);
173 tokval = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, seps);
174 }
175 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "SCRIPT") == 0) {
176 strcpy(Netgamecxx . . $ Netgame..scriptnamecxx . . $ netgame_info#scriptname., tokval);
177 // Do this so the script can still have spaces
178 tokval = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, seps);
179 while (tokval) {
180 strcat(Netgamecxx . . $ Netgame..scriptnamecxx . . $ netgame_info#scriptname., " ");
181 strcat(Netgamecxx . . $ Netgame..scriptnamecxx . . $ netgame_info#scriptname., tokval);
182 tokval = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, seps);
183 }
184 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "PPS") == 0) {
185 Netgamecxx . . $ Netgame..packets_per_secondcxx . . $ netgame_info#packets_per_second. = atoi(tokval);
186 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "PEERPEER") == 0) {
187 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(tokval, "true") == 0)
188 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!;
189 else
190 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!;
191 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "PERMISSABLE") == 0) {
192 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(tokval, "true") == 0)
193 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!;
194 else
195 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!;
196 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "RANDOMIZERESPAWN") == 0) {
197 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(tokval, "true") == 0)
198 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_RANDOMIZE_RESPAWNcxx . . $ `Descent3/multi_external.h:241:9`!;
199 else
200 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_RANDOMIZE_RESPAWNcxx . . $ `Descent3/multi_external.h:241:9`!;
201 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "ACCWEAP") == 0) {
202 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(tokval, "true") == 0)
203 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_USE_ACC_WEAPcxx . . $ `Descent3/multi_external.h:236:9`!;
204 else
205 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_USE_ACC_WEAPcxx . . $ `Descent3/multi_external.h:236:9`!;
206 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "ROTVEL") == 0) {
207 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(tokval, "true") == 0)
208 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_SENDROTVELcxx . . $ `Descent3/multi_external.h:231:9`!;
209 else
210 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_SENDROTVELcxx . . $ `Descent3/multi_external.h:231:9`!;
211 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "USESMOOTHING") == 0) {
212 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(tokval, "true") == 0)
213 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_USE_SMOOTHINGcxx . . $ `Descent3/multi_external.h:237:9`!;
214 else
215 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_USE_SMOOTHINGcxx . . $ `Descent3/multi_external.h:237:9`!;
216 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "BRIGHTPLAYERS") == 0) {
217 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(tokval, "true") == 0)
218 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_BRIGHT_PLAYERScxx . . $ `Descent3/multi_external.h:238:9`!;
219 else
220 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_BRIGHT_PLAYERScxx . . $ `Descent3/multi_external.h:238:9`!;
221 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "MAXPLAYERS") == 0) {
222 Netgamecxx . . $ Netgame..max_playerscxx . . $ netgame_info#max_players. = atoi(tokval);
223 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "RESPAWNTIME") == 0) {
224 Netgamecxx . . $ Netgame..respawn_timecxx . . $ netgame_info#respawn_time. = atoi(tokval);
225 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "KILLGOAL") == 0) {
226 Netgamecxx . . $ Netgame..killgoalcxx . . $ netgame_info#killgoal. = atoi(tokval);
227 if (Netgamecxx . . $ Netgame..killgoalcxx . . $ netgame_info#killgoal.)
228 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_KILLGOALcxx . . $ `Descent3/multi_external.h:227:9`!;
229 else
230 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_KILLGOALcxx . . $ `Descent3/multi_external.h:227:9`!;
231
232 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "TIMELIMIT") == 0) {
233 Netgamecxx . . $ Netgame..timelimitcxx . . $ netgame_info#timelimit. = atoi(tokval);
234 if (Netgamecxx . . $ Netgame..timelimitcxx . . $ netgame_info#timelimit.)
235 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_TIMERcxx . . $ `Descent3/multi_external.h:226:9`!;
236 else
237 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_TIMERcxx . . $ `Descent3/multi_external.h:226:9`!;
238 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "OBJBAN") == 0) {
239 objid = FindObjectIDNamecxx . . $ FindObjectIDName(5c4306d8553b3696).(tokval);
240 if (objid != -1) {
241 Object_infocxx . . $ Object_info.[objid].multi_allowedcxx . . $ object_info#multi_allowed. = 0;
242 }
243 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "SHIPBAN") == 0) {
244 // Do this so the name can have spaces
245 char buf[100];
246 strcpy(buf, tokval);
247 tokval = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, seps);
248 while (tokval) {
249 strcat(buf, " ");
250 strcat(buf, tokval);
251 tokval = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, seps);
252 }
253 PlayerSetShipPermissioncxx . . $ PlayerSetShipPermission(fb2bb0cf4ad3de37).(-1, buf, 0);
254 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "MLOOK") == 0) {
255 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(tokval, "true") == 0)
256 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_ALLOW_MLOOKcxx . . $ `Descent3/multi_external.h:242:9`!;
257 else
258 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_ALLOW_MLOOKcxx . . $ `Descent3/multi_external.h:242:9`!;
259 } else if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(toklabel, "DIFFICULTY") == 0) {
260 Netgamecxx . . $ Netgame..difficultycxx . . $ netgame_info#difficulty. = atoi(tokval);
261 if ((Netgamecxx . . $ Netgame..difficultycxx . . $ netgame_info#difficulty. > 4) || (Netgamecxx . . $ Netgame..difficultycxx . . $ netgame_info#difficulty. < 0))
262 Netgamecxx . . $ Netgame..difficultycxx . . $ netgame_info#difficulty. = 0;
263 } else {
264 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Unknown line in multiplayer config file %s\t%s\n", toklabel, tokval);
265 }
266 };
267 return 1;
268 }