Debian Codegraph @

Descent3/gamepath.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/gamepath.cpp $
21 * $Revision: 15 $
22 * $Date: 10/08/98 4:23p $
23 * $Author: Kevin $
24 *
25 * Game automated path routines.
26 *
27 * $Log: /DescentIII/main/gamepath.cpp $
28 *
29 * 15 10/08/98 4:23p Kevin
30 * Changed code to comply with memory library usage. Always use mem_malloc
31 * , mem_free and mem_strdup
32 *
33 * 14 2/10/98 10:48a Matt
34 * Moved editor code from gamepath.cpp to epath.cpp
35 *
36 * 13 2/05/98 4:25p Chris
37 * Fixed a few bugs in the path system, improved the insert node function,
38 * and made the fvec and uvec of the node work (is even loaded and saved)
39 * correctly.
40 *
41 * 12 2/05/98 1:42p Chris
42 * Fixed the problems with DrawNumber. It use to only be able to draw
43 * numbers between 0 and 9.
44 *
45 * 11 2/04/98 6:09p Matt
46 * Changed object room number to indicate a terrain cell via a flag. Got
47 * rid of the object flag which used to indicate terrain.
48 *
49 * 10 2/03/98 5:01p Chris
50 * UPdated the path system
51 *
52 * 9 2/02/98 8:16p Chris
53 * FIxed some problems and added some functionality
54 *
55 * 8 1/27/98 12:01p Chris
56 * Game path system now works with new, load, and save in the editor.
57 * Also, the game path system is further bug proved.
58 *
59 * 7 1/26/98 6:32p Chris
60 * Incremental fixes to the path system.
61 *
62 * 6 12/23/97 6:18p Samir
63 * Moved all gr.h references to EDITOR block.
64 *
65 * 5 9/17/97 1:22p Samir
66 * BIG SEGMENT RIPOUT
67 *
68 * $NoKeywords: $
69 */
70
71 #include "gamepath.h"cxx . . $ `<file>/Descent3/gamepath.h`/
72 #include <stdlib.h>
73 #include <string.h>
74 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
75 #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/
76
77 game_pathcxx . . $ game_path# GamePathscxx . . $ GamePaths.[MAX_GAME_PATHScxx . . $ `Descent3/gamepath.h:51:9`!];
78 int Num_game_pathscxx . . $ Num_game_paths. = 0;
79
80 // Frees gamepath n for future use
81 void FreeGamePathcxx . . $ FreeGamePath(d4f767463ce0a6b3).(int n) {
82 if (!GamePathscxx . . $ GamePaths.[n].usedcxx . . $ game_path#used.)
83 return;
84
85 mem_freecxx . . $ `mem/mem.h:80:9`!(GamePaths[n].pathnodes);
86 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Path %d lost some\n", n);
87
88 GamePathscxx . . $ GamePaths.[n].num_nodescxx . . $ game_path#num_nodes. = 0;
89 GamePathscxx . . $ GamePaths.[n].usedcxx . . $ game_path#used. = 0;
90 Num_game_pathscxx . . $ Num_game_paths.--;
91 }
92
93 void InitGamePathscxx . . $ InitGamePaths(49f6e7a06ebc5aa8).() {
94 static bool f_game_paths_init = false;
95 int i;
96
97 if (f_game_paths_init) {
98 // Clear out the current path info
99 for (i = 0; i < MAX_GAME_PATHScxx . . $ `Descent3/gamepath.h:51:9`!; i++) {
100 FreeGamePathcxx . . $ FreeGamePath(d4f767463ce0a6b3).(i);
101 }
102 }
103
104 f_game_paths_init = true;
105
106 for (i = 0; i < MAX_GAME_PATHScxx . . $ `Descent3/gamepath.h:51:9`!; i++) {
107 GamePathscxx . . $ GamePaths.[i].num_nodescxx . . $ game_path#num_nodes. = 0;
108 GamePathscxx . . $ GamePaths.[i].usedcxx . . $ game_path#used. = 0;
109 }
110
111 Num_game_pathscxx . . $ Num_game_paths. = 0;
112 }
113
114 // searches through GamePath index and returns index of path matching name
115 // returns -1 if not found
116 int FindGamePathNamecxx . . $ FindGamePathName(5c4306d8553b3696).(const char *name) {
117 int i;
118
119 for (i = 0; i < MAX_GAME_PATHScxx . . $ `Descent3/gamepath.h:51:9`!; i++) {
120 if (GamePathscxx . . $ GamePaths.[i].usedcxx . . $ game_path#used. && !stricmpcxx . . $ `linux/linux_fix.h:43:9`!(GamePaths[i].name, name))
121 return i;
122 }
123 return -1;
124 }