Debian Codegraph @

Descent3/gametexture.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/gametexture.cpp $
21 * $Revision: 57 $
22 * $Date: 4/19/00 5:07p $
23 * $Author: Matt $
24 *
25 * <GameTexture--Texture management at the game level>
26 *
27 * $Log: /DescentIII/Main/gametexture.cpp $
28 *
29 * 57 4/19/00 5:07p Matt
30 * From Duane for 1.4
31 * Added checks, asserts, and fixes for bad return values
32 *
33 * 56 10/21/99 6:34p Matt
34 * Mac merge
35 *
36 * 55 5/23/99 7:43p Jason
37 * fixed briefing problem with lowmem textures
38 *
39 * 54 5/07/99 7:22p Jason
40 * changes for cards with low videomemory
41 *
42 * 53 4/30/99 5:06p Kevin
43 * misc dedicated server, networking and low memory enhancements
44 *
45 * 52 4/22/99 3:23p Jason
46 *
47 * 51 4/17/99 6:15p Samir
48 * replaced gr.h with grdefs.h and fixed resulting compile bugs.
49 *
50 * 50 4/13/99 12:03p Jason
51 * more memory savings for dedicated server
52 *
53 * 49 4/12/99 3:04p Jason
54 * changes for low memory
55 *
56 * 48 4/09/99 7:04p Jason
57 * changed some texture defines
58 *
59 * 47 4/01/99 1:21p Jason
60 * don't resize huge textures
61 *
62 * 46 3/30/99 6:01p Jason
63 * added new procedural effect
64 *
65 * 45 2/12/99 3:37p Jason
66 * added client-side interpolation...its not fully debugged though.
67 *
68 * 44 2/10/99 3:38p Jason
69 * table file filter fixups
70 *
71 * 43 1/29/99 6:29p Jason
72 * first pass at adding bumpmaps
73 *
74 * 42 1/22/99 3:59p Jason
75 * added 256x256 textures to help with terrain skies
76 *
77 * 41 1/21/99 11:15p Jeff
78 * pulled out some structs and defines from header files and moved them
79 * into seperate header files so that multiplayer dlls don't require major
80 * game headers, just those new headers. Side effect is a shorter build
81 * time. Also cleaned up some header file #includes that weren't needed.
82 * This affected polymodel.h, object.h, player.h, vecmat.h, room.h,
83 * manage.h and multi.h
84 *
85 * 40 1/18/99 11:11a Jason
86 * made vclips be specular
87 *
88 * 39 11/30/98 5:50p Jason
89 * added 4444 bitmap support
90 *
91 * 38 10/21/98 9:47a Kevin
92 *
93 * 37 10/20/98 6:22p Jason
94 * added superlowmem mode
95 *
96 * 36 10/14/98 5:50p Jason
97 * added lowmem modes for quartering textures
98 *
99 * 35 10/13/98 1:26p Jason
100 * made new detail level settings work
101 *
102 * 34 10/08/98 2:27p Jason
103 * sped up table file loading
104 *
105 * 33 10/07/98 5:03p Jason
106 * more options for textures
107 *
108 * 32 10/01/98 2:47p Jason
109 * added timed procedurals
110 *
111 * 31 8/13/98 11:57a Jason
112 * added water procedurals
113 *
114 * 30 7/31/98 10:50a Jason
115 * fixed memory leak
116 *
117 * 29 7/16/98 12:41p Jason
118 * fixed dumb bug
119 *
120 * 28 7/14/98 6:50p Jason
121 * made procedurals save out to the table file
122 *
123 * 27 7/09/98 7:30p Jason
124 * more procedural stuff
125 *
126 * 26 7/07/98 4:12p Jason
127 * checkin for procedurals
128 *
129 * 25 7/06/98 12:55p Jason
130 * added first pass at procedurals
131 *
132 * 24 6/10/98 12:21p Matt
133 * Revamped system that controls what textures are displayed on the
134 * texture tab. Should work correctly now, and will now save the settings
135 * to the registry. Also, textures now default to no type set, not all
136 * types set.
137 *
138 * 23 5/20/98 5:44p Jason
139 * incremental checkin for bumpmapping
140 *
141 * 22 5/20/98 1:08p Jason
142 * more stuff for adding bumpmaps
143 *
144 * 21 5/14/98 2:38p Jason
145 * made temp solution for vclip residency problem
146 *
147 * 20 5/14/98 2:17p Jason
148 * more changes to be memory friendly
149 *
150 * 19 3/17/98 4:52p Jason
151 * fixed compiler warning
152 *
153 * 17 3/17/98 4:33p Jason
154 * Added size changing to bitmaps/textures
155 *
156 * 16 2/13/98 12:40p Jason
157 * added functions to touch all data in a level when the level is loaded
158 *
159 * 15 2/11/98 4:58p Jason
160 * fixed some memory problems with resizing and mipping
161 *
162 * 14 2/10/98 11:38a Matt
163 * Ripped out the obsolete merge stuff
164 *
165 * 13 12/19/97 6:07p Jason
166 * sped up bitmap loading
167 *
168 * 12 12/19/97 2:46p Jason
169 * implemented bitmap paging routines
170 *
171 * 11 10/30/97 12:02p Jason
172 * fixed an error checking bug
173 *
174 * 10 10/21/97 12:06p Jason
175 * added mprintf warning to resizing of textures
176 *
177 * 9 10/20/97 6:20p Mark
178 * FROM JASON: Fixed dumb no-name bug
179 *
180 * 8 10/15/97 5:20p Jason
181 * did a HUGE overhaul of the bitmap system
182 *
183 * 7 10/13/97 3:56p Jason
184 * made a better 3d bitmap system
185 *
186 * 6 9/12/97 4:00p Matt
187 * If a game texture is not used, return the handle for the error bitmap
188 *
189 * 5 8/19/97 1:20p Jason
190 * set reflectivity to .5 by default
191 *
192 * 4 8/08/97 12:58p Jason
193 * got texture sliding and pingponging working
194 *
195 * 3 8/04/97 3:28p Jason
196 * added alpha blending per texture
197 *
198 * 21 6/17/97 2:53p Matt
199 * Allow 128x128 tmap2s over 64x64 tmap1s by scaling up the bottom
200 * texture. This is only temporary, because I think we'll be totally
201 * revising the tmap2 system.
202 *
203 * 20 6/06/97 3:57p Jason
204 * implemented changes for small textures and automatic tmap2 recognition
205 *
206 * 19 6/03/97 3:28p Jason
207 * fixed texturing problems
208 *
209 * 18 5/27/97 4:39p Jason
210 * changes to support OpenGL
211 *
212 * 17 5/23/97 7:07p Matt
213 * Added code, data, & dialogs to keep track of what a texture is used for
214 * (mine, terrain, object) so we can display in the texture dialog only
215 * the ones we're interested in.
216 *
217 * 16 5/19/97 5:10p Jason
218 * changes for our new abstracted renderer code
219 *
220 * 15 5/13/97 2:24p Jason
221 * fixed a couple of animating texture bugs
222 *
223 * 14 5/13/97 12:45p Matt
224 * Fixed bug in rotated cases of 16-bit texmerge
225 *
226 * 13 5/12/97 11:41a Jason
227 * made game work (default) to 16bit no mip maps mode
228 * Saves us alot of memory
229 *
230 * 12 5/12/97 11:19a Matt
231 * Worked on 16-bit merge code, which is still broken
232 *
233 * 11 5/02/97 7:28p Matt
234 * Got tmap2 system working, though I think the merge for 16-bit textures
235 * probably doesn't work
236 *
237 * 10 4/28/97 6:36p Jason
238 * fixed a bug with vclips
239 *
240 * 9 4/25/97 3:59p Jason
241 * fixed a bug that my last checkin caused
242 *
243 * 8 4/25/97 3:31p Jason
244 * implemented better memory management for vclips and bitmaps
245 *
246 * 7 4/21/97 5:29p Jason
247 * got animating textures to work on polygonal objects
248 *
249 * 6 2/19/97 3:23p Jason
250 * added hooks to import animated iffs
251 *
252 * 5 2/19/97 11:37a Jason
253 * take gametime into consideration when animating a vclip
254 *
255 * 4 2/11/97 3:21p Jason
256 * added MakeTexture8Bit function
257 *
258 * 3 1/25/97 5:55p Jason
259 * changes to support new 8bit palettized textures and vclips
260 *
261 * 2 1/16/97 3:01p Jason
262 * moved all Gametexture management stuff to the game level instead of in
263 * the texmap libarry.
264 *
265 * $NoKeywords: $
266 */
267
268 #include "grdefs.h"cxx . . $ `<file>/lib/grdefs.h`/
269 #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/
270 #include "gametexture.h"cxx . . $ `<file>/Descent3/gametexture.h`/
271 #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/
272 #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/
273 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
274 #include "vclip.h"cxx . . $ `<file>/Descent3/vclip.h`/
275 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
276 #include "bumpmap.h"cxx . . $ `<file>/lib/bumpmap.h`/
277 #include <stdlib.h>
278 #include <string.h>
279 #include "procedurals.h"cxx . . $ `<file>/Descent3/procedurals.h`/
280 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
281 #include "config.h"cxx . . $ `<file>/Descent3/config.h`/
282 #include "args.h"cxx . . $ `<file>/Descent3/args.h`/
283 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
284
285 // TODO: MTS: this is only used in this file.
286 int Num_texturescxx . . $ Num_textures. = 0;
287 texturecxx . . $ texture# GameTexturescxx . . $ GameTextures.[MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`!];
288
289 extern bool Mem_superlow_memory_modecxx . . $ Mem_superlow_memory_mode.;
290
291 static int Total_memory_savedcxx . . $ Total_memory_saved. = 0;
292
293 void FreeAllTexturescxx . . $ FreeAllTextures(49f6e7a06ebc5aa8).() {
294 for (int i = 0; i < MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`!; i++) {
295 if (GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used.)
296 FreeTexturecxx . . $ FreeTexture(d4f767463ce0a6b3).(i);
297 }
298 }
299
300 int InitTexturescxx . . $ InitTextures(b126dc7c1de90089).() {
301 // Initalizes the texture system
302
303 int i, tex;
304
305 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Initializing texture system.\n");
306 for (i = 0; i < MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`!; i++)
307 GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used. = 0;
308
309 tex = AllocTexturecxx . . $ AllocTexture(b126dc7c1de90089).();
310 GameTexturescxx . . $ GameTextures.[tex].bm_handlecxx . . $ texture#bm_handle. = BAD_BITMAP_HANDLEcxx . . $ `lib/bitmap.h:42:9`!;
311 strcpy(GameTexturescxx . . $ GameTextures.[tex].namecxx . . $ texture#name., "SAMPLE TEXTURE");
312
313 // Initialize procedural tables and such
314 InitProceduralscxx . . $ InitProcedurals(49f6e7a06ebc5aa8).();
315
316 atexitcxx . . $ atexit(cc8c495369588262).(FreeAllTexturescxx . . $ FreeAllTextures(49f6e7a06ebc5aa8).);
317
318 return 1;
319 }
320
321 // Set aside a texture for use
322 // This function returns a valid texture handle
323 int AllocTexturecxx . . $ AllocTexture(b126dc7c1de90089).(void) {
324 int i;
325
326 for (i = 0; i < MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`!; i++)
327 if (GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used. == 0)
328 break;
329
330 ASSERTcxx . . $ `misc/pserror.h:246:9`!(i != MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`!); // we've run out of texture slots
331
332 Num_texturescxx . . $ Num_textures.++;
333
334 memset(&GameTexturescxx . . $ GameTextures.[i], 0, sizeof(texturecxx . . $ texture#));
335
336 GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used. = 1;
337
338 GameTexturescxx . . $ GameTextures.[i].corona_typecxx . . $ texture#corona_type. = 0;
339 GameTexturescxx . . $ GameTextures.[i].bumpmapcxx . . $ texture#bumpmap. = -1;
340 GameTexturescxx . . $ GameTextures.[i].proceduralcxx . . $ texture#procedural. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
341 GameTexturescxx . . $ GameTextures.[i].namecxx . . $ texture#name.[0] = 0;
342 GameTexturescxx . . $ GameTextures.[i].flagscxx . . $ texture#flags. = 0; // default to no type
343 GameTexturescxx . . $ GameTextures.[i].alphacxx . . $ texture#alpha. = 1.0;
344 GameTexturescxx . . $ GameTextures.[i].speedcxx . . $ texture#speed. = 1.0;
345 GameTexturescxx . . $ GameTextures.[i].reflectivitycxx . . $ texture#reflectivity. = .6f;
346 GameTexturescxx . . $ GameTextures.[i].bm_handlecxx . . $ texture#bm_handle. = -1;
347 GameTexturescxx . . $ GameTextures.[i].destroy_handlecxx . . $ texture#destroy_handle. = -1;
348
349 return i;
350 }
351
352 // Searches thru all textures for a specific name, returns -1 if not found
353 // or index of texture with name
354 int FindTextureNamecxx . . $ FindTextureName(5c4306d8553b3696).(const char *name) {
355 int i, num_counted = 0;
356 ;
357
358 ASSERTcxx . . $ `misc/pserror.h:246:9`!(name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
359
360 for (i = 0; i < MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`! && num_counted < Num_texturescxx . . $ Num_textures.; i++) {
361 if (GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used.) {
362 num_counted++;
363 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(name, GameTextures[i].name))
364 return i;
365 }
366 }
367
368 return -1;
369 }
370
371 // Searches thru all textures for a bitmap of a specific name, returns -1 if not found
372 // or index of texture with name
373 int FindTextureBitmapNamecxx . . $ FindTextureBitmapName(5c4306d8553b3696).(const char *name) {
374 int i;
375
376 ASSERTcxx . . $ `misc/pserror.h:246:9`!(name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
377
378 for (i = 0; i < MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`!; i++) {
379 if (GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used.) {
380 if (GameTexturescxx . . $ GameTextures.[i].flagscxx . . $ texture#flags. & TF_ANIMATEDcxx . . $ `Descent3/gametexture.h:207:9`!) {
381 int not_res = 0;
382 if (GameVClipscxx . . $ GameVClips.[GameTexturescxx . . $ GameTextures.[i].bm_handlecxx . . $ texture#bm_handle.].flagscxx . . $ vclip#flags. & VCF_NOT_RESIDENTcxx . . $ `Descent3/vclip.h:31:9`!)
383 not_res = 1;
384
385 PageInVClipcxx . . $ PageInVClip(d4f767463ce0a6b3).(GameTexturescxx . . $ GameTextures.[i].bm_handlecxx . . $ texture#bm_handle.);
386 vclipcxx . . $ vclip# *vc = &GameVClipscxx . . $ GameVClips.[GameTexturescxx . . $ GameTextures.[i].bm_handlecxx . . $ texture#bm_handle.];
387 ASSERTcxx . . $ `misc/pserror.h:246:9`!(vc->used);
388
389 int t;
390 int retval = -1;
391
392 for (t = 0; t < vc->num_framescxx . . $ vclip#num_frames. && retval == -1; t++)
393 if ((!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(GameBitmaps[vc->frames[t]].name, name)))
394 retval = i;
395
396 if (retval != -1)
397 return retval;
398 } else {
399 if ((!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(GameBitmaps[GameTextures[i].bm_handle].name, name)))
400 return i;
401 }
402 }
403 }
404
405 return -1;
406 }
407
408 // Allocates memory for a procedural that is attached to a texture
409 int AllocateProceduralForTexturecxx . . $ AllocateProceduralForTexture(7864480464b09eea).(int handle) {
410 int w, h;
411
412 if (GameTexturescxx . . $ GameTextures.[handle].flagscxx . . $ texture#flags. & TF_TEXTURE_64cxx . . $ `Descent3/gametexture.h:214:9`!) {
413 w = h = 64;
414 } else if (GameTexturescxx . . $ GameTextures.[handle].flagscxx . . $ texture#flags. & TF_TEXTURE_32cxx . . $ `Descent3/gametexture.h:216:9`!) {
415 w = h = 32;
416 } else {
417 w = h = 128;
418 }
419
420 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural. = (proc_structcxx . . $ proc_struct# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(proc_struct));
421 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[handle].procedural);
422
423 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc1cxx . . $ proc_struct#proc1. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
424 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc2cxx . . $ proc_struct#proc2. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
425
426 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->last_evaluation_timecxx . . $ proc_struct#last_evaluation_time. = 0;
427 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->osc_timecxx . . $ proc_struct#osc_time. = 0;
428 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->osc_valuecxx . . $ proc_struct#osc_value. = 8;
429
430 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->procedural_bitmapcxx . . $ proc_struct#procedural_bitmap. = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(w, h, 0);
431 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[handle].procedural->procedural_bitmap >= 0);
432
433 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->memory_typecxx . . $ proc_struct#memory_type. = PROC_MEMORY_TYPE_NONEcxx . . $ `Descent3/gametexture.h:246:9`!;
434
435 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->palettecxx . . $ proc_struct#palette. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(256 * 2);
436
437 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->last_procedural_framecxx . . $ proc_struct#last_procedural_frame. = -1;
438 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->heatcxx . . $ proc_struct#heat. = 128;
439
440 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->dynamic_proc_elementscxx . . $ proc_struct#dynamic_proc_elements. = -1;
441 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
442
443 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->num_static_elementscxx . . $ proc_struct#num_static_elements. = 0;
444
445 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->lightcxx . . $ proc_struct#light. = 1;
446 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->thicknesscxx . . $ proc_struct#thickness. = 4;
447
448 memcpy(GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->palettecxx . . $ proc_struct#palette., DefaultProcPalettecxx . . $ DefaultProcPalette., 256 * 2);
449
450 return 1;
451 }
452
453 // Allocates the memory needed for static elements for a procedural texture
454 void AllocateStaticProceduralsForTexturecxx . . $ AllocateStaticProceduralsForTexture(3e454b8ccf442868).(int handle, int num_elements) {
455 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements. =
456 (static_proc_elementcxx . . $ static_proc_element# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(static_proc_element) * num_elements);
457 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[handle].procedural->static_proc_elements);
458 }
459
460 // Frees the memory used by static procedural elements
461 void FreeStaticProceduralsForTexturecxx . . $ FreeStaticProceduralsForTexture(d4f767463ce0a6b3).(int handle) {
462 if (GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements.)
463 mem_freecxx . . $ `mem/mem.h:80:9`!(GameTextures[handle].procedural->static_proc_elements);
464 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
465 }
466
467 // Given a texture handle, returns that textures bitmap
468 // If the texture is animated, returns framenum mod num_of_frames in the animation
469 // Force is to force the evaluation of a procedural
470 // Also figures in gametime
471 int GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(int handle, int framenum, bool force) {
472 int src_bitmap;
473
474 if (!GameTexturescxx . . $ GameTextures.[handle].usedcxx . . $ texture#used.)
475 return 0;
476
477 if (GameTexturescxx . . $ GameTextures.[handle].flagscxx . . $ texture#flags. & TF_ANIMATEDcxx . . $ `Descent3/gametexture.h:207:9`!) {
478 float cur_frametime;
479 int int_frame;
480 texturecxx . . $ texture# *tex = &GameTexturescxx . . $ GameTextures.[handle];
481 PageInVClipcxx . . $ PageInVClip(d4f767463ce0a6b3).(GameTexturescxx . . $ GameTextures.[handle].bm_handlecxx . . $ texture#bm_handle.);
482
483 vclipcxx . . $ vclip# *vc = &GameVClipscxx . . $ GameVClips.[GameTexturescxx . . $ GameTextures.[handle].bm_handlecxx . . $ texture#bm_handle.];
484 ASSERTcxx . . $ `misc/pserror.h:246:9`!(vc->used >= 1);
485
486 if (GameTexturescxx . . $ GameTextures.[handle].flagscxx . . $ texture#flags. & TF_PING_PONGcxx . . $ `Descent3/gametexture.h:219:9`!) {
487 // Ping pong this texture
488
489 float frametime = tex->speedcxx . . $ texture#speed. / vc->num_framescxx . . $ vclip#num_frames.;
490 cur_frametime = Gametimecxx . . $ Gametime. / frametime;
491 int_frame = cur_frametime;
492 int_frame += framenum;
493
494 int_frame %= (vc->num_framescxx . . $ vclip#num_frames. * 2);
495 if (int_frame >= vc->num_framescxx . . $ vclip#num_frames.)
496 int_frame = (vc->num_framescxx . . $ vclip#num_frames. - 1) - (int_frame % vc->num_framescxx . . $ vclip#num_frames.);
497 else
498 int_frame %= vc->num_framescxx . . $ vclip#num_frames.;
499 src_bitmap = vc->framescxx . . $ vclip#frames.[int_frame];
500 } else {
501 float frametime = tex->speedcxx . . $ texture#speed. / vc->num_framescxx . . $ vclip#num_frames.;
502 cur_frametime = Gametimecxx . . $ Gametime. / frametime;
503 int_frame = cur_frametime;
504 int_frame += framenum;
505 src_bitmap = vc->framescxx . . $ vclip#frames.[int_frame % vc->num_framescxx . . $ vclip#num_frames.];
506 }
507 } else {
508 src_bitmap = GameTexturescxx . . $ GameTextures.[handle].bm_handlecxx . . $ texture#bm_handle.;
509 }
510
511 if (GameTexturescxx . . $ GameTextures.[handle].flagscxx . . $ texture#flags. & TF_PROCEDURALcxx . . $ `Descent3/gametexture.h:225:9`!) // Do a procedural
512 {
513 int do_eval = 1;
514
515 if (GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
516 AllocateProceduralForTexturecxx . . $ AllocateProceduralForTexture(7864480464b09eea).(handle);
517
518 if (GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->last_procedural_framecxx . . $ proc_struct#last_procedural_frame. == FrameCountcxx . . $ FrameCount.)
519 do_eval = 0;
520 if (timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!() <
521 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->last_evaluation_timecxx . . $ proc_struct#last_evaluation_time. + GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->evaluation_timecxx . . $ proc_struct#evaluation_time.)
522 do_eval = 0;
523
524 if (!force && !Detail_settingscxx . . $ Detail_settings..Procedurals_enabledcxx . . $ tDetailSettings#Procedurals_enabled.) {
525 if (timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!() < GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->last_evaluation_timecxx . . $ proc_struct#last_evaluation_time. + 10.0)
526 do_eval = 0;
527 }
528
529 if (do_eval) {
530 EvaluateProceduralcxx . . $ EvaluateProcedural(d4f767463ce0a6b3).(handle);
531 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->last_procedural_framecxx . . $ proc_struct#last_procedural_frame. = FrameCountcxx . . $ FrameCount.;
532 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->last_evaluation_timecxx . . $ proc_struct#last_evaluation_time. = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!();
533 src_bitmap = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->procedural_bitmapcxx . . $ proc_struct#procedural_bitmap.;
534 GameBitmapscxx . . $ GameBitmaps.[src_bitmap].flagscxx . . $ bms_bitmap#flags. |= BF_CHANGEDcxx . . $ `lib/bitmap.h:46:9`!;
535 } else
536 src_bitmap = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->procedural_bitmapcxx . . $ proc_struct#procedural_bitmap.;
537 }
538
539 return src_bitmap;
540 }
541
542 // Given a filename, loads either the bitmap or vclip found in that file. If type
543 // is not NULL, sets it to 1 if file is animation, otherwise sets it to zero
544 int LoadTextureImagecxx . . $ LoadTextureImage(f997a6335c8241fb).(const char *filename, int *type, int texture_size, int mipped, int pageable, int format) {
545 int anim = 0, bm_handle;
546 char extension[10];
547 int w, h;
548
549 int len = strlen(filename);
550
551 if (len < 4)
552 return -1;
553
554 strncpy(extension, &filename[len - 3], 5);
555
556 if ((!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!("oaf", extension, 3)) || (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!("ifl", extension, 3)) || (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!("abm", extension, 3)))
557 anim = 1;
558
559 if (type != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
560 *type = anim;
561
562 if (anim)
563 bm_handle = AllocLoadVClipcxx . . $ AllocLoadVClip(cf529e05df08c24).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(filename), texture_size, mipped, pageable, format);
564 else {
565 if (pageable)
566 bm_handle = bm_AllocLoadFileNoMemBitmapcxx . . $ bm_AllocLoadFileNoMemBitmap(1163be050dbfff7).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(filename), mipped, format);
567 else
568 bm_handle = bm_AllocLoadFileBitmapcxx . . $ bm_AllocLoadFileBitmap(1163be050dbfff7).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(filename), mipped, format);
569
570 if (bm_handle < 1)
571 return -1;
572
573 if (texture_size == NORMAL_TEXTUREcxx . . $ `Descent3/gametexture.h:239:9`!) {
574 w = TEXTURE_WIDTHcxx . . $ `lib/renderer.h:308:9`!;
575 h = TEXTURE_HEIGHTcxx . . $ `lib/renderer.h:309:9`!;
576 } else if (texture_size == SMALL_TEXTUREcxx . . $ `Descent3/gametexture.h:240:9`!) {
577 // Make small textures a quarter of the size of normal textures
578 w = TEXTURE_WIDTHcxx . . $ `lib/renderer.h:308:9`! / 2;
579 h = TEXTURE_HEIGHTcxx . . $ `lib/renderer.h:309:9`! / 2;
580 } else if (texture_size == TINY_TEXTUREcxx . . $ `Descent3/gametexture.h:241:9`!) {
581 // Make these tinys an eigth of the size of normal textures
582 w = TEXTURE_WIDTHcxx . . $ `lib/renderer.h:308:9`! / 4;
583 h = TEXTURE_HEIGHTcxx . . $ `lib/renderer.h:309:9`! / 4;
584 } else if (texture_size == HUGE_TEXTUREcxx . . $ `Descent3/gametexture.h:242:9`!) {
585 // Make these tinys an eigth of the size of normal textures
586 w = TEXTURE_WIDTHcxx . . $ `lib/renderer.h:308:9`! * 2;
587 h = TEXTURE_HEIGHTcxx . . $ `lib/renderer.h:309:9`! * 2;
588 } else
589 return bm_handle;
590
591 // If differing size, resize!
592 if (!pageable && (w != bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0) || h != bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0))) {
593 int dest_bm;
594
595 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "WARNING: Resizing bitmap %s from %d x %d to %d x %d!\n", GameBitmaps[bm_handle].name,
596 bm_w(bm_handle, 0), bm_h(bm_handle, 0), w, h);
597
598 dest_bm = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(w, h, mipped * ((w * h * 2) / 3));
599 ASSERTcxx . . $ `misc/pserror.h:246:9`!(dest_bm >= 0);
600
601 if (mipped)
602 GameBitmapscxx . . $ GameBitmaps.[dest_bm].flagscxx . . $ bms_bitmap#flags. |= BF_MIPMAPPEDcxx . . $ `lib/bitmap.h:47:9`!;
603 GameBitmapscxx . . $ GameBitmaps.[dest_bm].formatcxx . . $ bms_bitmap#format. = format;
604
605 bm_ScaleBitmapToBitmapcxx . . $ bm_ScaleBitmapToBitmap(3e454b8ccf442868).(dest_bm, bm_handle);
606 strcpy(GameBitmapscxx . . $ GameBitmaps.[dest_bm].namecxx . . $ bms_bitmap#name., GameBitmapscxx . . $ GameBitmaps.[bm_handle].namecxx . . $ bms_bitmap#name.);
607 bm_FreeBitmapcxx . . $ bm_FreeBitmap(d4f767463ce0a6b3).(bm_handle);
608
609 bm_handle = dest_bm;
610 }
611 }
612
613 return bm_handle;
614 }
615
616 // Goes through and marks a texture as a tmap2 if its bitmap(s) have transparency
617 bool CheckIfTextureIsTmap2cxx . . $ CheckIfTextureIsTmap2(83c267b20bac841a).(int texnum) {
618 if (GameTexturescxx . . $ GameTextures.[texnum].flagscxx . . $ texture#flags. & TF_ANIMATEDcxx . . $ `Descent3/gametexture.h:207:9`!) {
619 vclipcxx . . $ vclip# *vc = &GameVClipscxx . . $ GameVClips.[GameTexturescxx . . $ GameTextures.[texnum].bm_handlecxx . . $ texture#bm_handle.];
620 PageInVClipcxx . . $ PageInVClip(d4f767463ce0a6b3).(GameTexturescxx . . $ GameTextures.[texnum].bm_handlecxx . . $ texture#bm_handle.);
621
622 ASSERTcxx . . $ `misc/pserror.h:246:9`!(vc->used);
623 for (int i = 0; i < vc->num_framescxx . . $ vclip#num_frames.; i++) {
624 if (bm_SetBitmapIfTransparentcxx . . $ bm_SetBitmapIfTransparent(7864480464b09eea).(vc->framescxx . . $ vclip#frames.[i])) {
625 GameTexturescxx . . $ GameTextures.[texnum].flagscxx . . $ texture#flags. |= TF_TMAP2cxx . . $ `Descent3/gametexture.h:215:9`!;
626 return 1;
627 }
628 }
629 } else {
630 if (bm_SetBitmapIfTransparentcxx . . $ bm_SetBitmapIfTransparent(7864480464b09eea).(GameTexturescxx . . $ GameTextures.[texnum].bm_handlecxx . . $ texture#bm_handle.)) {
631 GameTexturescxx . . $ GameTextures.[texnum].flagscxx . . $ texture#flags. |= TF_TMAP2cxx . . $ `Descent3/gametexture.h:215:9`!;
632 return 1;
633 }
634 }
635
636 return 0;
637 }
638
639 extern int Low_vidmemcxx . . $ Low_vidmem.;
640 // Pages a texture into memory, optionally resizing it if in low mem mode
641 // Doesn't resize if resize is false
642 void PageInTexturecxx . . $ PageInTexture(918ebd27a9ddbad3).(int n, bool resize) {
643 static int super_low_mem = -1;
644
645 if (super_low_mem == -1) {
646 if (Mem_superlow_memory_modecxx . . $ Mem_superlow_memory_mode. || FindArgcxx . . $ FindArg(5c4306d8553b3696).("-dedicated"))
647 super_low_mem = 1;
648 else
649 super_low_mem = 0;
650 }
651 if (GameTexturescxx . . $ GameTextures.[n].usedcxx . . $ texture#used. == 0)
652 return;
653
654 texturecxx . . $ texture# *texp = &GameTexturescxx . . $ GameTextures.[n];
655
656 bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(texp->bm_handlecxx . . $ texture#bm_handle., 0);
657
658 #ifndef EDITOR
659 if (resize == true && (Mem_low_memory_modecxx . . $ Mem_low_memory_mode. || Low_vidmemcxx . . $ Low_vidmem.))
660 {
661 if (!(texp->flagscxx . . $ texture#flags. & (TF_TEXTURE_32cxx . . $ `Descent3/gametexture.h:216:9`! | TF_TEXTURE_256cxx . . $ `Descent3/gametexture.h:229:9`!)) && !(texp->flagscxx . . $ texture#flags. & TF_PROCEDURALcxx . . $ `Descent3/gametexture.h:225:9`!)) {
662 int bm_handle = texp->bm_handlecxx . . $ texture#bm_handle.;
663 int w = TEXTURE_WIDTHcxx . . $ `lib/renderer.h:308:9`!, h = TEXTURE_HEIGHTcxx . . $ `lib/renderer.h:309:9`!;
664
665 if (texp->flagscxx . . $ texture#flags. & TF_TEXTURE_64cxx . . $ `Descent3/gametexture.h:214:9`!) {
666 w /= 2;
667 h /= 2;
668 }
669
670 w /= 2;
671 h /= 2;
672
673 if (super_low_mem)
674 {
675 if (w != 32 || h != 32) {
676 w = 32;
677 h = 32;
678 }
679 }
680
681 if ((w != bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0) || h != bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0))) {
682 int dest_bm;
683 int mipped = 0;
684 int saved = 0;
685
686 if (texp->flagscxx . . $ texture#flags. & TF_TEXTURE_64cxx . . $ `Descent3/gametexture.h:214:9`!)
687 saved = 6144;
688 else
689 saved = 24576;
690
691 if (bm_mippedcxx . . $ bm_mipped(7864480464b09eea).(bm_handle))
692 mipped = 1;
693
694 if (mipped)
695 saved += (saved / 3);
696
697 Total_memory_savedcxx . . $ Total_memory_saved. += saved;
698
699 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Low mem: Resizing bitmap %s to %d x %d!\n", GameBitmaps[bm_handle].name, w, h);
700 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Total memory saved=%d\n", Total_memory_saved);
701
702 dest_bm = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(w, h, mipped * ((w * h * 2) / 3));
703 ASSERTcxx . . $ `misc/pserror.h:246:9`!(dest_bm >= 0);
704 if (mipped)
705 GameBitmapscxx . . $ GameBitmaps.[dest_bm].flagscxx . . $ bms_bitmap#flags. |= BF_MIPMAPPEDcxx . . $ `lib/bitmap.h:47:9`!;
706
707 GameBitmapscxx . . $ GameBitmaps.[dest_bm].formatcxx . . $ bms_bitmap#format. = GameBitmapscxx . . $ GameBitmaps.[bm_handle].formatcxx . . $ bms_bitmap#format.;
708
709 bm_ScaleBitmapToBitmapcxx . . $ bm_ScaleBitmapToBitmap(3e454b8ccf442868).(dest_bm, bm_handle);
710 strcpy(GameBitmapscxx . . $ GameBitmaps.[dest_bm].namecxx . . $ bms_bitmap#name., GameBitmapscxx . . $ GameBitmaps.[bm_handle].namecxx . . $ bms_bitmap#name.);
711 bm_FreeBitmapcxx . . $ bm_FreeBitmap(d4f767463ce0a6b3).(bm_handle);
712
713 texp->bm_handlecxx . . $ texture#bm_handle. = dest_bm;
714 }
715 }
716 }
717 #endif
718 }
719
720 // Pages in this particular texture
721 void TouchTexturecxx . . $ TouchTexture(d4f767463ce0a6b3).(int n) {
722 if (GameTexturescxx . . $ GameTextures.[n].flagscxx . . $ texture#flags. & TF_ANIMATEDcxx . . $ `Descent3/gametexture.h:207:9`!) {
723 PageInVClipcxx . . $ PageInVClip(d4f767463ce0a6b3).(GameTexturescxx . . $ GameTextures.[n].bm_handlecxx . . $ texture#bm_handle.);
724 } else
725 PageInTexturecxx . . $ PageInTexture(918ebd27a9ddbad3).(n, true);
726 }
727
728 // Frees all the bumpmaps associated with a texture
729 void FreeTextureBumpmapscxx . . $ FreeTextureBumpmaps(d4f767463ce0a6b3).(int tex_handle) {
730 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[tex_handle].used > 0);
731
732 if (GameTexturescxx . . $ GameTextures.[tex_handle].bumpmapcxx . . $ texture#bumpmap. != -1) {
733 bump_FreeBumpmapcxx . . $ bump_FreeBumpmap(d4f767463ce0a6b3).(GameTexturescxx . . $ GameTextures.[tex_handle].bumpmapcxx . . $ texture#bumpmap.);
734 GameTexturescxx . . $ GameTextures.[tex_handle].bumpmapcxx . . $ texture#bumpmap. = -1;
735 }
736 }
737
738 // Builds the bumpmaps for the past in texture
739 void BuildTextureBumpmapscxx . . $ BuildTextureBumpmaps(d4f767463ce0a6b3).(int texhandle) {
740 int i, t;
741 int8_t *buffer;
742
743 if (GameTexturescxx . . $ GameTextures.[texhandle].flagscxx . . $ texture#flags. & TF_ANIMATEDcxx . . $ `Descent3/gametexture.h:207:9`!)
744 return; // No bumps for animated textures
745
746 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Calculating bumpmap for texture named %s.\n", GameTextures[texhandle].name);
747
748 // Make sure there is no bump already
749 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[texhandle].bumpmap == -1);
750
751 // Get width and height
752 int w = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(GameTexturescxx . . $ GameTextures.[texhandle].bm_handlecxx . . $ texture#bm_handle., 0);
753 int h = bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(GameTexturescxx . . $ GameTextures.[texhandle].bm_handlecxx . . $ texture#bm_handle., 0);
754
755 // Allocate a bumpmap
756 int bump = bump_AllocBumpmapcxx . . $ bump_AllocBumpmap(9b79fb6aee4c0440).(w, h);
757 ASSERTcxx . . $ `misc/pserror.h:246:9`!(bump != -1);
758 GameTexturescxx . . $ GameTextures.[texhandle].bumpmapcxx . . $ texture#bumpmap. = bump;
759
760 // allocate memory for our buffer
761 buffer = (int8_t *)mem_malloccxx . . $ `mem/mem.h:79:9`!(w * h);
762 ASSERTcxx . . $ `misc/pserror.h:246:9`!(buffer);
763
764 uint16_tcxx . . $ uint16_t# *src_data = (uint16_tcxx . . $ uint16_t# *)bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(GameTexturescxx . . $ GameTextures.[texhandle].bm_handlecxx . . $ texture#bm_handle., 0);
765
766 // create the grayscale
767 for (i = 0; i < h; i++) {
768 for (t = 0; t < w; t++) {
769 uint16_tcxx . . $ uint16_t# color = src_data[i * w + t];
770
771 int red = ((color >> 10) & 0x1f) << 3;
772 int green = ((color >> 5) & 0x1f) << 3;
773 int blue = ((color) & 0x1f) << 3;
774
775 buffer[i * w + t] = (int8_t)(0.29 * red + 0.60 * green + 0.11 * blue);
776 }
777 }
778
779 uint16_tcxx . . $ uint16_t# *dest_data = (uint16_tcxx . . $ uint16_t# *)bump_datacxx . . $ bump_data(2fbd6a760478ca0f).(bump);
780
781 for (i = 0; i < h; i++) {
782 int8_t *pDst = (int8_t *)(dest_data + i * w);
783 for (t = 0; t < w; t++) {
784 int v00, v01, v10;
785
786 v00 = buffer[(i * w + t)]; // Get current pixel. *3 for 24 bits src
787
788 if (t == w - 1) // Special case for last column
789 v01 = buffer[(i * w + t)]; // Get pixel to the right
790 else
791 v01 = buffer[(i * h + t + 1)]; // Get pixel to the right
792
793 if (i == h - 1) // Special case for last row
794 v10 = buffer[i * w + t]; // Get pixel one line below
795 else
796 v10 = buffer[((i + 1) * w) + t]; // Get pixel one line below
797
798 int iDu = v00 - v01; // The delta-u bump value
799 int iDv = v00 - v10; // The delta-v bump value
800 *pDst++ = (int8_t)iDu;
801 *pDst++ = (int8_t)iDv;
802 }
803 }
804
805 mem_freecxx . . $ `mem/mem.h:80:9`!(buffer);
806 }
807
808 // Frees all the procedural memory for a texture
809 void FreeProceduralForTexturecxx . . $ FreeProceduralForTexture(d4f767463ce0a6b3).(int n) {
810 if (GameTexturescxx . . $ GameTextures.[n].proceduralcxx . . $ texture#procedural. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
811 FreeStaticProceduralsForTexturecxx . . $ FreeStaticProceduralsForTexture(d4f767463ce0a6b3).(n);
812 mem_freecxx . . $ `mem/mem.h:80:9`!(GameTextures[n].procedural->proc1);
813 mem_freecxx . . $ `mem/mem.h:80:9`!(GameTextures[n].procedural->proc2);
814 bm_FreeBitmapcxx . . $ bm_FreeBitmap(d4f767463ce0a6b3).(GameTexturescxx . . $ GameTextures.[n].proceduralcxx . . $ texture#procedural.->procedural_bitmapcxx . . $ proc_struct#procedural_bitmap.);
815 mem_freecxx . . $ `mem/mem.h:80:9`!(GameTextures[n].procedural->palette);
816 mem_freecxx . . $ `mem/mem.h:80:9`!(GameTextures[n].procedural);
817
818 GameTexturescxx . . $ GameTextures.[n].proceduralcxx . . $ texture#procedural. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
819 }
820 }
821
822 // Frees a texture that is being used and
823 // Decrements number of textures in use
824 void FreeTexturecxx . . $ FreeTexture(d4f767463ce0a6b3).(int n) {
825 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[n].used);
826
827 FreeTextureBumpmapscxx . . $ FreeTextureBumpmaps(d4f767463ce0a6b3).(n);
828
829 GameTexturescxx . . $ GameTextures.[n].usedcxx . . $ texture#used. = 0;
830 GameTexturescxx . . $ GameTextures.[n].namecxx . . $ texture#name.[0] = 0;
831 Num_texturescxx . . $ Num_textures.--;
832
833 FreeProceduralForTexturecxx . . $ FreeProceduralForTexture(d4f767463ce0a6b3).(n);
834 }
835
836 // Given current index, gets index of next texture in use
837 int GetNextTexturecxx . . $ GetNextTexture(7864480464b09eea).(int n) {
838 int i;
839
840 if (Num_texturescxx . . $ Num_textures. == 0)
841 return -1;
842
843 for (i = n + 1; i < MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`!; i++) {
844 if (GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used.)
845 return i;
846 }
847 for (i = 0; i < n; i++) {
848 if (GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used.)
849 return i;
850 }
851
852 return n;
853 }
854 // Given current index, gets index of prev texture in use
855 int GetPreviousTexturecxx . . $ GetPreviousTexture(7864480464b09eea).(int n) {
856 int i;
857
858 if (Num_texturescxx . . $ Num_textures. == 0)
859 return -1;
860
861 for (i = n - 1; i >= 0; i--) {
862 if (GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used.)
863 return i;
864 }
865 for (i = MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`! - 1; i > n; i--) {
866 if (GameTexturescxx . . $ GameTextures.[i].usedcxx . . $ texture#used.)
867 return i;
868 }
869
870 return n;
871 }