Debian Codegraph @

Descent3/door.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/door.cpp $
21 * $Revision: 12 $
22 * $Date: 2/04/99 2:05p $
23 * $Author: Matt $
24 *
25 * doorway and side info.
26 *
27 * $Log: /DescentIII/main/door.cpp $
28 *
29 * 12 2/04/99 2:05p Matt
30 * Added blastable doors
31 *
32 * 11 1/29/99 12:47p Matt
33 * Rewrote the doorway system
34 *
35 * 10 1/21/99 11:15p Jeff
36 * pulled out some structs and defines from header files and moved them
37 * into seperate header files so that multiplayer dlls don't require major
38 * game headers, just those new headers. Side effect is a shorter build
39 * time. Also cleaned up some header file #includes that weren't needed.
40 * This affected polymodel.h, object.h, player.h, vecmat.h, room.h,
41 * manage.h and multi.h
42 *
43 * 9 4/06/98 4:53p Jason
44 * got pageable polymodels working correctly with editor
45 *
46 * 8 4/02/98 3:54p Jason
47 * first pass in getting polymodel paging to work
48 *
49 * 7 2/02/98 7:07p Matt
50 * Added support for doors that can be seen through even when closed
51 *
52 * 6 10/06/97 1:01p Jason
53 * made doors work with scripts (sort of)
54 *
55 * 5 9/17/97 11:16a Matt
56 * Ripped out segment code
57 *
58 * 4 9/12/97 5:38p Jason
59 * got doors working
60 *
61 * 3 9/09/97 7:02p Jason
62 * don't reload the models during the remap phase
63 *
64 * 2 8/07/97 12:42p Jason
65 * fixed potential memory problem
66 *
67 * 18 5/23/97 5:46p Matt
68 * Added SetMatrixBasedOnSide() functionality to ExtractMatrixFromSeg().
69 *
70 * 17 4/02/97 5:21p Jason
71 * added the ability for pages to free the models that they point to
72 *
73 * 16 3/18/97 5:22p Jason
74 * took out dumb mprintf
75 *
76 * 15 3/14/97 5:54p Jason
77 * made positional interpolation work with 3d doors
78 *
79 * 14 3/13/97 6:23p Jason
80 * fixed a door bug
81 *
82 * 13 3/13/97 6:13p Jason
83 * got poly doors working
84 *
85 * 12 3/12/97 2:15p Samir
86 * Removed global references to doorways.
87 *
88 * 11 3/12/97 12:40p Samir
89 * Adding doorway open code
90 *
91 * 10 3/10/97 4:07p Samir
92 * We now almost nevert render the texture in a door segment
93 *
94 * 9 3/07/97 2:19p Jason
95 * added DrawDoorSegment function
96 *
97 * 8 3/05/97 3:10p Jason
98 * added more door functionality
99 *
100 * 7 3/05/97 3:03p Jason
101 * added blinking messages
102 *
103 * 6 3/05/97 2:27p Samir
104 *
105 * 5 3/05/97 12:16p Jason
106 * added code to support our new 3d doors
107 *
108 * 4 2/27/97 5:09p Samir
109 * Key flags defined in door code.
110 *
111 * 3 2/26/97 4:25p Samir
112 * Call GetDoorFlags to get door info.
113 *
114 * 2 2/25/97 4:35p Samir
115 * Added SIDE_FLAGS macro.
116 *
117 * $NoKeywords: $
118 */
119
120 #include <string.h>
121
122 #include "door.h"cxx . . $ `<file>/Descent3/door.h`/
123 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
124 #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/
125 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
126 #include "doorway.h"cxx . . $ `<file>/Descent3/doorway.h`/
127
128 // ---------------------------------------------------------------------------
129 // Globals
130
131 doorcxx . . $ door# Doorscxx . . $ Doors.[MAX_DOORScxx . . $ `Descent3/door.h:143:9`!]; // door info.
132 int Num_doorscxx . . $ Num_doors. = 0;
133
134 // ---------------------------------------------------------------------------
135 // Prototypes
136
137 // ---------------------------------------------------------------------------
138 // Functions
139
140 // Sets all doors to unused
141 void InitDoorscxx . . $ InitDoors(49f6e7a06ebc5aa8).() {
142 for (int i = 0; i < MAX_DOORScxx . . $ `Descent3/door.h:143:9`!; i++) {
143 memset(&Doorscxx . . $ Doors.[i], 0, sizeof(doorcxx . . $ door#));
144 Doorscxx . . $ Doors.[i].model_handlecxx . . $ door#model_handle. = -1;
145 // Doors[i].script_name[0] = 0;
146 }
147 Num_doorscxx . . $ Num_doors. = 0;
148 }
149
150 // Allocs a door for use, returns -1 if error, else index on success
151 int AllocDoorcxx . . $ AllocDoor(b126dc7c1de90089).() {
152 for (int i = 0; i < MAX_DOORScxx . . $ `Descent3/door.h:143:9`!; i++) {
153 if (Doorscxx . . $ Doors.[i].usedcxx . . $ door#used. == 0) {
154 Doorscxx . . $ Doors.[i].usedcxx . . $ door#used. = 1;
155 // Doors[i].script_name[0] = 0;
156 Doorscxx . . $ Doors.[i].flagscxx . . $ door#flags. = 0;
157 Doorscxx . . $ Doors.[i].hit_pointscxx . . $ door#hit_points. = 0.0;
158 Num_doorscxx . . $ Num_doors.++;
159 return i;
160 }
161 }
162
163 Int3cxx . . $ `misc/pserror.h:247:9`!(); // No doors free!
164 return -1;
165 }
166
167 // Frees door index n
168 void FreeDoorcxx . . $ FreeDoor(d4f767463ce0a6b3).(int n) {
169 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Doors[n].used > 0);
170
171 Doorscxx . . $ Doors.[n].usedcxx . . $ door#used. = 0;
172 Doorscxx . . $ Doors.[n].namecxx . . $ door#name.[0] = 0;
173 Num_doorscxx . . $ Num_doors.--;
174 }
175
176 // Gets next door from n that has actually been alloced
177 int GetNextDoorcxx . . $ GetNextDoor(7864480464b09eea).(int n) {
178 int i;
179
180 ASSERTcxx . . $ `misc/pserror.h:246:9`!(n >= 0 && n < MAX_DOORScxx . . $ `Descent3/door.h:143:9`!);
181
182 if (Num_doorscxx . . $ Num_doors. == 0)
183 return -1;
184
185 for (i = n + 1; i < MAX_DOORScxx . . $ `Descent3/door.h:143:9`!; i++)
186 if (Doorscxx . . $ Doors.[i].usedcxx . . $ door#used.)
187 return i;
188 for (i = 0; i < n; i++)
189 if (Doorscxx . . $ Doors.[i].usedcxx . . $ door#used.)
190 return i;
191
192 // this is the only one
193
194 return n;
195 }
196
197 // Gets previous door from n that has actually been alloced
198 int GetPrevDoorcxx . . $ GetPrevDoor(7864480464b09eea).(int n) {
199 int i;
200
201 ASSERTcxx . . $ `misc/pserror.h:246:9`!(n >= 0 && n < MAX_DOORScxx . . $ `Descent3/door.h:143:9`!);
202
203 if (Num_doorscxx . . $ Num_doors. == 0)
204 return -1;
205
206 for (i = n - 1; i >= 0; i--) {
207 if (Doorscxx . . $ Doors.[i].usedcxx . . $ door#used.)
208 return i;
209 }
210 for (i = MAX_DOORScxx . . $ `Descent3/door.h:143:9`! - 1; i > n; i--) {
211 if (Doorscxx . . $ Doors.[i].usedcxx . . $ door#used.)
212 return i;
213 }
214
215 // this is the only one
216 return n;
217 }
218 // Searches thru all doors for a specific name, returns -1 if not found
219 // or index of door with name
220 int FindDoorNamecxx . . $ FindDoorName(5c4306d8553b3696).(const char *name) {
221 int i;
222
223 ASSERTcxx . . $ `misc/pserror.h:246:9`!(name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
224
225 for (i = 0; i < MAX_DOORScxx . . $ `Descent3/door.h:143:9`!; i++)
226 if (Doorscxx . . $ Doors.[i].usedcxx . . $ door#used. && !stricmpcxx . . $ `linux/linux_fix.h:43:9`!(name, Doors[i].name))
227 return i;
228
229 return -1;
230 }
231
232 // Given a filename, loads the model found in that file
233
234 int LoadDoorImagecxx . . $ LoadDoorImage(cb7559238bb26814).(const char *filename, int pageable) {
235 int img_handle;
236
237 img_handle = LoadPolyModelcxx . . $ LoadPolyModel(220e687f58daa9be).(filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., pageable);
238
239 return img_handle;
240 }
241
242 // Given a door handle, returns an index to that doors model
243 int GetDoorImagecxx . . $ GetDoorImage(7864480464b09eea).(int handle) {
244 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Doors[handle].used > 0);
245
246 return (Doorscxx . . $ Doors.[handle].model_handlecxx . . $ door#model_handle.);
247 }
248
249 void RemapDoorscxx . . $ RemapDoors(49f6e7a06ebc5aa8).() {
250 // Now, if any doors are polygon models and those models don't have correct
251 // textures, attempt to reload the model texture list
252
253 for (int i = 0; i < MAX_DOORScxx . . $ `Descent3/door.h:143:9`!; i++) {
254 if (Doorscxx . . $ Doors.[i].usedcxx . . $ door#used.) {
255 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Doors[i].model_handle != -1);
256 // LoadPolyModel (Poly_models[Doors[i].model_handle].name);
257 }
258 }
259 }