Debian Codegraph @

Descent3/marker.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
19 #include "object.h"cxx . . $ `<file>/Descent3/object.h`/
20 #include "marker.h"cxx . . $ `<file>/Descent3/marker.h`/
21 #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/
22 #include "player.h"cxx . . $ `<file>/Descent3/player.h`/
23 #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/
24 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
25 #ifdef _DEBUGcxx . . $ `<built-in>:482:9`!
26 #include "AIMain.h"cxx . . $ `<file>/Descent3/AIMain.h`/
27 #endif
28
29 int Marker_polynumcxx . . $ Marker_polynum.;
30 int Marker_messagecxx . . $ Marker_message. = 0;
31
32 char MarkerMessagescxx . . $ MarkerMessages.[MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`! * 2][MAX_MARKER_MESSAGE_LENGTHcxx . . $ `Descent3/marker.h:24:9`!];
33
34 // Drops a market at the players current position
35 void DropMarkercxx . . $ DropMarker(fda57c8427c60377).(char *message) {
36 int cur_marker_num;
37
38 #ifdef _DEBUGcxx . . $ `<built-in>:482:9`!
39 char teststring[80];
40 strcpy(teststring, message);
41 teststring[8] = '\0';
42
43 if (strcmp("ai debug", teststring) == 0) {
44 sscanf(message, "ai debug %d", &AI_debug_robot_indexcxx . . $ AI_debug_robot_index.);
45 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Debug robot is object index %d\n", AI_debug_robot_index);
46 }
47 #endif
48
49 if (Player_objectcxx . . $ Player_object.->typecxx . . $ object#type. != OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!)
50 return;
51
52 if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) {
53 MultiSendRequestForMarkercxx . . $ MultiSendRequestForMarker(fda57c8427c60377).(message);
54 return;
55 }
56
57 int limit = 8;
58
59 if (Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].num_markerscxx . . $ player#num_markers. >= limit) {
60 // Delete the oldest marker
61 int found = -1;
62 float low_time = 999999999.0f;
63 for (int i = 0; i <= Highest_object_indexcxx . . $ Highest_object_index.; i++) {
64 if (Objectscxx . . $ Objects.[i].typecxx . . $ object#type. == OBJ_MARKERcxx . . $ `Descent3/object_external.h:175:9`! && Objectscxx . . $ Objects.[i].parent_handlecxx . . $ object#parent_handle. == Player_objectcxx . . $ Player_object.->handlecxx . . $ object#handle. &&
65 Objectscxx . . $ Objects.[i].creation_timecxx . . $ object#creation_time. < low_time) {
66 found = i;
67 low_time = Objectscxx . . $ Objects.[i].creation_timecxx . . $ object#creation_time.;
68 }
69 }
70
71 ASSERTcxx . . $ `misc/pserror.h:246:9`!(found != -1);
72
73 ObjDeletecxx . . $ ObjDelete(d4f767463ce0a6b3).(found);
74
75 cur_marker_num = Objectscxx . . $ Objects.[found].idcxx . . $ object#id.;
76 } else {
77 cur_marker_num = Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].num_markerscxx . . $ player#num_markers.;
78 Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].num_markerscxx . . $ player#num_markers.++;
79 }
80
81 int objnum = ObjCreatecxx . . $ ObjCreate(849c3da80a4f387f).(OBJ_MARKERcxx . . $ `Descent3/object_external.h:175:9`!, cur_marker_num, Player_objectcxx . . $ Player_object.->roomnumcxx . . $ object#roomnum., &Player_objectcxx . . $ Player_object.->poscxx . . $ object#pos.,
82 &Player_objectcxx . . $ Player_object.->orientcxx . . $ object#orient., Player_objectcxx . . $ Player_object.->handlecxx . . $ object#handle.);
83 if (objnum >= 0) {
84 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Marker %d created!\n", cur_marker_num);
85 strcpy(MarkerMessagescxx . . $ MarkerMessages.[(Player_numcxx . . $ Player_num. * 2) + cur_marker_num], message);
86 } else
87 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Marker NOT created!\n");
88 }
89
90 // Resets markers before a level stars
91 void ResetMarkerscxx . . $ ResetMarkers(49f6e7a06ebc5aa8).() { Marker_messagecxx . . $ Marker_message. = 0; }
92
93 // Inits markers at game load
94 void InitMarkerscxx . . $ InitMarkers(49f6e7a06ebc5aa8).() {
95 Marker_polynumcxx . . $ Marker_polynum. = LoadPolyModelcxx . . $ LoadPolyModel(220e687f58daa9be).("marker.oof"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., 0);
96 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Marker_polynum >= 0);
97 }