Debian Codegraph @

Descent3/LoadLevel.h

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/LoadLevel.h $
21 * $Revision: 130 $
22 * $Date: 10/21/99 3:27p $
23 * $Author: Gwar $
24 *
25 * Header for LoadLevel.cpp
26 *
27 * $Log: /DescentIII/Main/LoadLevel.h $
28 *
29 * 130 10/21/99 3:27p Gwar
30 * changes to keep NEWEDITOR compatibility with D3 v1.2 and earlier (for
31 * now)
32 *
33 * 129 10/14/99 1:08p Chris
34 * Added another custom bounce force field texture slot
35 *
36 * 128 10/13/99 2:19p Chris
37 * Added the ability to disable wind for powerups on a level
38 *
39 * 127 10/13/99 10:41a Chris
40 * Added 'special forcefields' that have custom bounce factors
41 *
42 * 126 10/08/99 4:28p Chris
43 * Added the forcefield and glass breaking override options
44 *
45 * 125 8/12/99 5:26p Matt
46 * Added a chunk to store room wind vectors.
47 *
48 * 124 5/23/99 3:06a Jason
49 * save editor lighting settings
50 *
51 * 123 5/18/99 11:13a Matt
52 * Added variable ceiling height.
53 *
54 * 122 5/03/99 3:28p Jason
55 * save out lightmap spacing
56 *
57 * 121 4/29/99 1:59a Chris
58 * Added the portal blockage support
59 *
60 * 120 4/26/99 10:32p Chris
61 * Improving the BNode system
62 *
63 * 119 4/26/99 11:11a Chris
64 * Updated Bnode system
65 *
66 * 118 4/21/99 12:40p Chris
67 * Added the FVI_always_check_ceiling flag
68 *
69 * 117 4/18/99 5:39a Chris
70 * Vastly improved the path node system
71 *
72 * 116 4/14/99 3:56a Jeff
73 * fixed case mismatch in #includes
74 *
75 * 115 4/05/99 3:34p Matt
76 * Cleaned up player start flags
77 *
78 * 114 3/27/99 5:36p Matt
79 * Save sounds by name instead of index
80 *
81 * 113 3/24/99 5:53p Jason
82 * added per room ambience settings
83 *
84 * 112 3/10/99 7:12p Jason
85 * added smooth specular shading for curved surfaces
86 *
87 * 111 2/28/99 9:28p Matt
88 * Cleaned up load level error handing and version checking.
89 *
90 * 110 2/26/99 3:26p Jason
91 * made satellites clip properly
92 *
93 * 109 2/21/99 4:20p Matt
94 * Added SoundSource objects (and reformatted parts of the object header
95 * files).
96 *
97 * 108 2/21/99 12:29p Matt
98 * Added terrain sound system
99 *
100 * 107 2/19/99 12:10p Jason
101 * fixed dumb (but major) bug with last rev
102 *
103 * 106 2/19/99 12:04p Jason
104 * took out sky band
105 *
106 * 105 2/18/99 12:32p Jason
107 * added room multiplier
108 *
109 * 104 2/14/99 3:27p Chris
110 * FIxed a load/save bug... hehe
111 *
112 * 103 2/10/99 1:49p Matt
113 * Don't have parent_handle, since it's always none.
114 *
115 * 102 2/09/99 9:58a Chris
116 * Massive BOA update :) Terrain happy now. Vis happy now. Sound happy
117 * now.
118 *
119 * 101 2/04/99 2:05p Matt
120 * Added blastable doors
121 *
122 * 100 2/03/99 5:48p Matt
123 * Added room damage system
124 *
125 * 99 2/03/99 12:15p Jason
126 * added multiplayer vis optimizations
127 *
128 * 98 1/29/99 12:48p Matt
129 * Rewrote the doorway system
130 *
131 * 97 1/22/99 8:53p Jeff
132 * added custom-default script overrides
133 *
134 * 96 1/22/99 3:59p Jason
135 * added 256x256 textures to help with terrain skies
136 *
137 * 95 1/21/99 11:34a Matt
138 * Got rid of portal triggers. Since we don't have multi-face portals, a
139 * face trigger works fine for a portal. Also fixed a few editor/trigger
140 * bugs.
141 *
142 * 94 1/20/99 10:50a Jason
143 * added new terrain
144 *
145 * 93 1/18/99 2:46p Matt
146 * Combined flags & flags2 fields in object struct
147 *
148 * 92 1/15/99 3:14p Jason
149 * added combinable portals
150 *
151 * 91 1/14/99 11:06a Matt
152 * Added names to triggers
153 *
154 * 90 1/08/99 5:37p Samir
155 * reverb values per room.
156 *
157 * 89 1/08/99 2:55p Samir
158 * Ripped out OSIRIS1.
159 *
160 * 88 12/22/98 2:03p Matt
161 * Added room names, and made rooms not compress so that room numbers are
162 * suitable for persistant uses.
163 *
164 * 87 12/21/98 11:30p Matt
165 * Added names for objects
166 *
167 * 86 12/21/98 6:00p Matt
168 * Changed the object handle bit allocation to handle object numbers up to
169 * 2047.
170 * Increased MAX_OBJECTS to 1500.
171 *
172 * 85 12/18/98 5:40p Chris
173 * Ambient life is now all sequenced up
174 *
175 * 84 12/11/98 1:55p Chris
176 * Reduced BOA's size and changed how it works with no path situations
177 *
178 * 83 12/02/98 5:06p Jason
179 * First pass at getting mega-lightmaps wprking
180 *
181 * 82 11/30/98 5:26p Jason
182 * more lightmap changes
183 *
184 * 81 11/30/98 3:59p Jason
185 * changed dynamic lighting to be better
186 *
187 * 80 11/18/98 4:30p Jason
188 * added some functionality to terrain fog
189 *
190 * 79 11/11/98 11:41a Jason
191 * added sunlight damage
192 *
193 * 78 11/02/98 6:15p Chris
194 * Room AABBs get saved with the level and the sort_face and dec_sort_face
195 * list s have been removed
196 *
197 * 77 10/19/98 5:40p Samir
198 * added loading level callback.
199 *
200 * 76 10/17/98 11:11p Matt
201 * Added room memory allocation system
202 *
203 * 75 10/05/98 2:42a Chris
204 * Level goals are relatively functional
205 *
206 * 74 9/24/98 5:41p Chris
207 * Designers can save out gravity changes
208 *
209 * 73 9/18/98 7:25p Matt
210 * Put in code to handle a bunch of renamed doors.
211 *
212 * 72 9/04/98 12:29p Matt
213 * Added marked edge & vertex in the editor
214 *
215 * 71 9/01/98 12:04p Matt
216 * Ripped out multi-face portal code
217 *
218 * 70 8/27/98 5:19p Jason
219 * added first rev of reflected surfaces
220 *
221 * 69 8/17/98 6:40p Matt
222 * Added ambient sound system
223 *
224 * 68 8/10/98 11:25a Jason
225 * added better specular lighting
226 *
227 * 67 7/20/98 6:07p Jason
228 * Save BOA vis checksum to file
229 *
230 * 66 7/20/98 12:04p Jason
231 * added per level satellite lighting
232 *
233 * 65 6/10/98 12:23p Jason
234 * added new skies
235 *
236 * 64 6/05/98 5:22p Jason
237 * added volumetric fog
238 *
239 * 63 6/04/98 6:17p Jason
240 * added terrain occlusion system
241 *
242 * 62 6/02/98 6:03p Jason
243 * added specular lightmaps
244 *
245 * 61 5/26/98 7:07p Samir
246 * write out is_custom element of script structure for obejcts and
247 * triggers.
248 *
249 * 60 5/22/98 5:12p Jason
250 * save out sky radius
251 *
252 * 59 5/22/98 3:27p Jason
253 * added specular lighting
254 *
255 * 58 5/15/98 5:41p Jason
256 * implemented volume lighting system
257 *
258 * 57 5/14/98 12:56p Jason
259 * changes to help lower memory usage
260 *
261 * 56 5/04/98 1:12a Chris
262 * Added parenting bug checking
263 *
264 * 55 4/23/98 7:48p Jason
265 * made older levels work with new 1555 format
266 *
267 * 54 4/22/98 12:38p Chris
268 * Added path points to portals and rooms. Improved BOA auto-making
269 * process.
270 *
271 * 53 4/20/98 12:46p Jason
272 * added level checksumming for multiplayer games
273 *
274 * 52 4/03/98 10:23a Chris
275 * BOA cost array is saved out
276 *
277 * 51 4/02/98 12:24p Jason
278 * trimmed some fat from our structures
279 *
280 * 50 3/29/98 11:58p Jason
281 * saved some memory with object lightmaps
282 *
283 * 49 3/27/98 7:29p Jason
284 * changed lightmap normals to work correctly
285 *
286 * 48 3/26/98 2:14p Jason
287 * added dynamic lighting for objects
288 *
289 * 47 2/27/98 3:15p Jason
290 * Don't save terrain pixel error stuff
291 *
292 * 46 2/17/98 8:58p Jason
293 * took out loading/saving of useless rgbl data
294 *
295 * 45 2/15/98 8:01p Matt
296 * Save wireframe view info in level file
297 *
298 * 44 2/13/98 12:52p Jason
299 * made lighting multipliers work in quarter steps instead of whole steps
300 *
301 * 43 2/10/98 3:49p Jason
302 * added pulsing walls
303 *
304 * 42 2/05/98 4:25p Chris
305 * Fixed a few bugs in the path system, improved the insert node function,
306 * and made the fvec and uvec of the node work (is even loaded and saved)
307 * correctly.
308 *
309 * 41 2/04/98 8:25p Jason
310 * added light multiplier for faces
311 *
312 * 40 2/04/98 6:09p Matt
313 * Changed object room number to indicate a terrain cell via a flag. Got
314 * rid of the object flag which used to indicate terrain.
315 *
316 * 39 2/02/98 4:21p Samir
317 * Now we save trigger script parameter info properly.
318 *
319 * 38 1/21/98 12:32p Matt
320 * Revamped viewer system
321 *
322 * 37 1/20/98 4:12p Samir
323 * Load and save script parameters.
324 *
325 * 36 1/19/98 10:04a Matt
326 * Added new object handle system
327 *
328 * 35 1/16/98 8:06p Jason
329 * added selectable halos and atmosphere blends to satellites
330 *
331 * 34 1/07/98 4:19p Jason
332 * added dome to terrain sky
333 *
334 * 33 12/31/97 12:51p Jason
335 * debugged and implementd BSP tree for lighting
336 *
337 * 32 12/17/97 5:26p Jason
338 * added support for selectable wraparound sky
339 *
340 * 31 11/25/97 12:28p Jason
341 * another pass at shadows
342 *
343 * 30 11/10/97 5:22p Jason
344 * made lightmap spacing use floats instead of ubytes
345 *
346 * 29 11/03/97 1:52p Jason
347 * compress lightmaps when reading/writing
348 *
349 * 28 10/21/97 11:08a Jason
350 * added check for OF_POLYGON_OBJECT
351 *
352 * 27 10/03/97 12:42p Jason
353 * save "keys_needed" info about doorways
354 *
355 * 26 10/02/97 12:09p Jason
356 * made object lightmaps save and load
357 *
358 * 25 10/01/97 7:51p Matt
359 * Added code for external rooms
360 *
361 * 24 9/29/97 12:09p Jason
362 * added functionality to doorway system
363 *
364 * 23 9/25/97 3:49p Jason
365 * sped up terrain reading/writing
366 *
367 * 22 9/24/97 6:18p Samir
368 * Use script names instead of script id values to identify scripts.
369 *
370 * 21 9/19/97 2:52p Jason
371 * changes to fix lightmap seam problem
372 *
373 * 20 9/16/97 4:22p Matt
374 * Don't save/load the (now deleted) static_light field in a room
375 *
376 * 19 9/12/97 5:38p Jason
377 * got doors working
378 *
379 * 18 9/12/97 2:35p Matt
380 * Save/load face flags as a word
381 *
382 * 17 9/10/97 1:59p Samir
383 * Added level version for script code storage in levels.
384 *
385 * 16 9/09/97 6:15p Jason
386 * Added groovy dynamic terrain lighting system
387 *
388 * 15 9/08/97 4:13p Jason
389 * added colored lighting for the terrain
390 *
391 * 14 9/08/97 12:16p Matt
392 * Save & Load portal number as byte
393 *
394 * 13 9/02/97 6:40p Matt
395 * Fixed code & added functions for group save/load
396 *
397 * 12 9/02/97 5:17p Jason
398 * changes for dynamic lighting
399 *
400 * 11 9/02/97 11:56a Jason
401 * saves alpha component
402 *
403 * 10 9/02/97 11:47a Matt
404 * Changed externs for read/write segment to read/write room
405 *
406 * 9 8/22/97 2:42p Jason
407 * added sky saving to loadlevel routines
408 *
409 * 8 8/13/97 11:52a Jason
410 * now saves lightmap info
411 *
412 * 7 8/12/97 10:29a Samir
413 * Read in a script handle per object in level.
414 *
415 * 6 8/11/97 1:53p Matt
416 * Ripped out robot & powerup pages, and added generic page
417 *
418 * 5 8/07/97 3:19p Jason
419 * replaced old terrain tmap system with new one
420 *
421 * 4 8/01/97 3:59p Jason
422 * added loading and saving of terrain chunks
423 *
424 * 3 7/24/97 3:23p Matt
425 * Saved several additional editor state variables
426 *
427 * 5 6/18/97 11:58a Jason
428 * first pass at getting new room engine stuff reading in
429 *
430 * 4 5/22/97 5:16p Jason
431 * added tmap2 capability to the terrain
432 *
433 * 3 5/13/97 11:58a Matt
434 * Made group file code save & load the level file version number to use
435 * when reading segments
436 *
437 * 2 3/12/97 3:23p Matt
438 * Make ReadSegment() and WriteSegment() public, and removed a bunch of
439 * version number passing that wasn't being used.
440 *
441 * 1 2/10/97 11:24a Matt
442 *
443 * $NoKeywords: $
444 */
445
446 #include "cfile.h"
447 #include "room.h"
448
449 // Chunk types
450 #define CHUNK_TEXTURE_NAMES "TXNM"
451 #define CHUNK_GENERIC_NAMES "GNNM"
452 #define CHUNK_ROBOT_NAMES "RBNM"
453 #define CHUNK_POWERUP_NAMES "PWNM"
454 #define CHUNK_DOOR_NAMES "DRNM"
455 #define CHUNK_ROOMS "ROOM"
456 #define CHUNK_ROOM_WIND "RWND"
457 #define CHUNK_OBJECTS "OBJS"
458 #define CHUNK_TERRAIN "TERR"
459 #define CHUNK_EDITOR_INFO "EDIT"
460 #define CHUNK_SCRIPT "SCPT"
461 #define CHUNK_TERRAIN_HEIGHT "TERH"
462 #define CHUNK_TERRAIN_TMAPS_FLAGS "TETM"
463 #define CHUNK_TERRAIN_LINKS "TLNK"
464 #define CHUNK_TERRAIN_SKY "TSKY"
465 #define CHUNK_TERRAIN_END "TEND"
466 #define CHUNK_SCRIPT_CODE "CODE"
467 #define CHUNK_TRIGGERS "TRIG"
468 #define CHUNK_LIGHTMAPS "LMAP"
469 #define CHUNK_BSP "CBSP"
470 #define CHUNK_OBJECT_HANDLES "OHND"
471 #define CHUNK_GAME_PATHS "PATH"
472 #define CHUNK_BOA "CBOA"
473 #define CHUNK_NEW_BSP "CNBS"
474 #define CHUNK_LEVEL_INFO "INFO"
475 #define CHUNK_PLAYER_STARTS "PSTR"
476 #define CHUNK_MATCEN_DATA "MTCN"
477 #define CHUNK_LEVEL_GOALS "LVLG"
478 #define CHUNK_ROOM_AABB "AABB"
479 #define CHUNK_NEW_LIGHTMAPS "NLMP"
480 #define CHUNK_ALIFE_DATA "LIFE"
481 #define CHUNK_TERRAIN_SOUND "TSND"
482 #define CHUNK_BNODES "NODE"
483 #define CHUNK_OVERRIDE_SOUNDS "OSND"
484 #define CHUNK_FFT_MOD "FFTM"
485
486 #ifndef NEWEDITOR // for compatibility with Descent 3 v1.2 and earlier
487 #define LEVEL_FILE_VERSION 132
488 #else
489 #define LEVEL_FILE_VERSION 128
490 #endif
491
492 // This is the oldest version the code will read
493 #define LEVEL_FILE_OLDEST_COMPATIBLE_VERSION 13
494
495 // Version numbers of specific changes
496 #define LEVEL_FILE_SCRIPTING 18
497 #define LEVEL_FILE_NEWSCRIPTING 26
498 #define LEVEL_FILE_SCRIPTNAMES 31
499 #define LEVEL_FILE_SCRIPTPARMS 46
500 #define LEVEL_FILE_TRIGPARMS 48
501 #define LEVEL_FILE_SCRIPTCHECK 70
502 #define LEVEL_FILE_OSIRIS1DEAD 97
503
504 // Version number changes:
505 // 0 -> 1 Save curseg & markedseg to file
506 // 1 -> 2 Save texture names to file & remap when load
507 // 2 -> 3 Save selected list
508 // 3 -> 4 Save triggers and doorways
509 // 4 -> 5 Save segnums as ints, not shorts. Also, save terrain height array
510 // 5 -> 6 Save & xlate names for robots, powerups, & doors
511 // 6 -> 7 Instead of saving a bunch of type-specific data, read it from the data page
512 // 7 -> 8 Now saves terrain sky data
513 // 8 -> 9 Now saves the mine/terrain links
514 // 9 ->10 Changes for floating segments
515 // 10->11 Added tmap2 textures to terrain
516 // 11->12 save u,v coords for terrain
517 // 12->13 New chunk-based file format to save room data
518 // 13->14 Save some more data in editor chunk
519 // 14->15 Saves terrain info in chunk format
520 // 15->16 Changes UV terrain chunk format
521 // 16->17 Generic objects replace robots & powerups
522 // 17->18 Custom script handle read and written for objects 8-11-97
523 // 18->19 Now saves lightmap info with room faces
524 // 19->20 Now saves mine/terrain links and sky info
525 // 20->21 Now saves alpha component per vertex
526 // 21->22 Now saves upper left vertex
527 // 22->23 Save portal num as byte
528 // 23->24 Saves RGB lighting for terrain
529 // 24->25 Saves terrain dynamic lighting table
530 // 25->26 If level isn't version 26 or above, then we need to ignore any script chunk, create a new one.
531 // 26->27 Save face flags as short
532 // 27->28 Store doorway information
533 // 28->29 Killed static light field in room struct
534 // 29->30 Store new lightmap_info information
535 // 30->31 Read in script names instead of handles for all objects.
536 // 31->32 Do RLE compression for terrain data
537 // 32->33 Save more info about doorways
538 // 33->34 Save object id as short
539 // 34->35 Save info about object lightmaps
540 // 35->36 Save "keys_needed" field for doorways
541 // 36->37 Do tricks to restore OF_POLYGON_OBJECT flag
542 // 37->38 Do RLE compression for lightmaps
543 // 38->39 Store lightmap spacing as floats,not ubytes
544 // 39->40 Save/load shadow rooms/faces
545 // 40->41 Save horizon texture info
546 // 41->42 Save BSP info for the mine
547 // 42->43 Save extra texture pieces for terrain sky
548 // 43->44 Save terrain satellite flags
549 // 44->45 Objects no longer compressed, so save objnum (handle,actually) with each object
550 // 45->46 Objects and triggers have optional script parameters. Also, compressed script info in object.
551 // 46->47 Only save one viewer id, not two
552 // 47->48 Read in trigger parameters too.
553 // 48->49 Objects now store terrain flag as part of roomnum
554 // 49->50 Store light multiplier per face
555 // 50->51 Store fvec/uvec of path nodes
556 // 51->52 Now saves/loads wall pulsing data
557 // 52->53 Face light multiple now works in quarter steps
558 // 54->55 Add wireframe view info to editor chunk
559 // 55->56 Don't read/write useless face info such as rgba
560 // 56->57 Don't read/write pixel error or terrain distance
561 // 57->58 Read uvec,rvec for lightmap infos
562 // 58->59 Store lightmap normals
563 // 59->60 Don't store lightmap normals for dynamic objects
564 // 60->61 Trimmed some fat from rooms,faces structures
565 // 61->62 BOA now saves out the portal cost array
566 // 62->63 We now save path_pnts with rooms and portals
567 // 62->64 Translate old 565 lightmaps into 1555 format
568 // 64->65 Added object parent_handles
569 // 65->66 Store lightmap spacing as bytes, not floats
570 // 66->67 Save volume lighting for rooms
571 // 67->68 Save specular lighting for rooms
572 // 68->69 Save terrain sky radius
573 // 69->70 Read in whether attached script is default or custom.
574 // 70->71 Threw out vertex based specularity and went with lightmap based specularity
575 // 71->72 Added terrain occlusion data
576 // 72->73 Now store volumetric fog info with room
577 // 73->74 Support for new banded-dome skies
578 // 74->75 Now supports satellite lighting values
579 // 75->76 Saves BOA_vis_checksum to file
580 // 76->77 Saves multiple specular values
581 // 77->78 Added ambient sound field to room
582 // 78->79 Added mirrored faces
583 // 79->80 New single-face portals
584 // 80->81 Save marked face & vert
585 // 81->82 Door name translation
586 // 82->83 Added gravity to level info
587 // 83->84 Added level goal information
588 // 84->85 Save the amount of memory needed by the rooms
589 // 85->86 Added room AABB information to save
590 // 86->87 Added damage per second for terrain sky
591 // 87->88 Add fog scalar for adjustable fog distance
592 // 88->89 Took out dynamic light data saving
593 // 89->90 Save out more than one lightmap_info per lightmap
594 // 90->91 Save out lightmap_info x1,y1 origin in megalightmap
595 // 91->92 Reduced boa save size
596 // 92->93 Ambeint Life
597 // 93->94 Changed object handle bit allocation
598 // 94->95 Added object names
599 // 95->96 Added room names, & took out room compression (so saved list can have holes)
600 // 96->97 Ripped out OSIRIS v1.0
601 // 97->98 ???
602 // 98->99 Added trigger names
603 // 99->100 Add combinable portals
604 // 100->101 Changed object flags from short to int, and only read certain flags
605 // 101->102 Changed terrain textures system
606 // 102->103 Removed portal triggers
607 // 103->104 Changed terrain sky system
608 // 104->105 Added custom_default_script_name and custom_default_module_name to objects
609 // 105->106 Rewrote doorway system
610 // 106->107 Save out BOA terrain info (temp, for vis and multiplay only)
611 // 107->108 Added room damage
612 // 108->109 Added blastable doors
613 // 109->110 Update BOA to its final form
614 // 109->111 Don't save an object's parent handle
615 // 111->112 Added BOA_connect information
616 // 112->113 Save room multipliers out with editor chunk
617 // 113->114 Took out band textures
618 // 114->115 Added soundsource objects
619 // 115->116 Save satellite sizes
620 // 116->117 added smooth specular mapping
621 // 117->118 added room ambience settings
622 // 118->119 Save sound names, not indices
623 // 119->120 Save the number of player starts to the file
624 // 120->121 Added the BOA Node chunk
625 // 121->122 Added the ability for a level to always have the ceiling checked
626 // 122->123 Added the bnode_index to portals...
627 // 122->124 Added the bnode verify flag
628 // 124->125 Removed the portal field from BNode edges as the room portals now contain bnode info (so it isn't necessary)
629 // 125->126 Save lightmap spacing info
630 // 126->127 Added ceiling value
631 // 127->128 Save rest of lighting parameters
632 // 128->129 Add the Override sound chunk
633 // 129->130 Added the modified force field bounce textures
634 // 130->131 Added the powerups ignore gravity checkbox
635 // 131->132 Added another ff bounce texture for Dan (his last day wish)
636
637 // Load a level file
638 // Returns 1 if file read ok, else 0
639 // cb_fn returns current chunk, parm1 = # bytes in chunk, parm2 = number of bytes in file
640 // parm1 = -1, for 1st just opened level
641 // parm2 = -2, for done loading.
642 int LoadLevel(char *filename, void (*cb_fn)(const char *, int, int) = NULL);
643
644 // Save a level file
645 // Returns 1 if file saved ok, else 0
646 int SaveLevel(char *filename, bool f_save_room_AABB = true);
647
648 // Reads a room from a disk file
649 // Parameters: ifile - file to read from
650 // rp - room to read
651 // version - version number of file
652 // Returns: 1 if read ok, else 0
653 int ReadRoom(CFILE *ifile, room *rp, int version);
654
655 // Writes a room to a disk file
656 // Parameters: ofile - file to write to
657 // rp - room to write
658 // Returns: 1 if written ok, else 0
659 int WriteRoom(CFILE *ofile, room *rp);
660
661 // Write the texture names for remapping when level is loaded
662 void WriteTextureList(CFILE *ofile);
663
664 // Read the texture names & build the xlate table
665 void ReadTextureList(CFILE *ifile);
666
667 // Primarily for multiplayer, makes sure the client and server levels are the same
668
669 #include "../md5/md5.h"
670 extern MD5 *Level_md5;
671 inline void RestartLevelMD5() {
672 if (Level_md5)
673 delete Level_md5;
674 Level_md5 = new MD5();
675 }
676
677 inline void AppendToLevelChecksum(int val) {
678 if (!Level_md5) {
679 return;
680 }
681 Level_md5->update(val);
682 }
683
684 inline void AppendToLevelChecksum(uint32_t val) {
685 if (!Level_md5) {
686 return;
687 }
688 Level_md5->update(val);
689 }
690
691 inline void AppendToLevelChecksum(uint16_t val) {
692 if (!Level_md5) {
693 return;
694 }
695 Level_md5->update(val);
696 }
697
698 inline void AppendToLevelChecksum(int16_t val) {
699 if (!Level_md5) {
700 return;
701 }
702 Level_md5->update(val);
703 }
704
705 inline void AppendToLevelChecksum(float val) {
706 if (!Level_md5) {
707 return;
708 }
709 Level_md5->update(val);
710 }
711
712 inline void AppendToLevelChecksum(vector val) {
713 if (!Level_md5) {
714 return;
715 }
716 Level_md5->update(val.x);
717 Level_md5->update(val.y);
718 Level_md5->update(val.z);
719 }
720
721 inline void AppendToLevelChecksum(uint8_t val) {
722 if (!Level_md5) {
723 return;
724 }
725 Level_md5->update(val);
726 }
727
728 inline void GetLevelMD5Sum(uint8_t digest[16]) {
729 if (!Level_md5) {
730 for (int i = 0; i < 16; i++)
731 digest[i] = 0;
732 return;
733 }
734 Level_md5->digest(digest);
735 }
736