Debian Codegraph @

src/mission.cpp

raw symbols SCIP
1 #cxx . . $ `<file>/src/mission.cpp`/include <stdio.h>
2 #include "mission.h"cxx . . $ `<file>/src/mission.h`/
3
4
5 // This function checks to see what our missions status should be. It
6 // returns MISSION_STARTED, MISSION_SUCCESS or MISSION_FAILED
7 // The old_status should also be one of these, indicating what our
8 // status was before this function was called.
9 // For example "my_mission = Mission_Status(Subs, my_mission);"
10 int Mission_Statuscxx . . $ Mission_Status(8e102eb2bbf433ac).(Submarinecxx . . $ Submarine# *all_subs, int old_status)
11 {
12 Submarinecxx . . $ Submarine# *current_sub;
13 int found;
14
15 // if the mission already failed it is too late to save it
16 if (old_status == MISSION_FAILEDcxx . . $ `src/mission.h:8:9`!)
17 return MISSION_FAILEDcxx . . $ `src/mission.h:8:9`!;
18
19 if (! all_subs)
20 return MISSION_FAILEDcxx . . $ `src/mission.h:8:9`!;
21
22 // go through each sub and check its status
23 current_sub = all_subs;
24 found = FALSEcxx . . $ `src/map.h:13:9`!;
25 while ( (current_sub) && (! found) )
26 {
27 if (current_sub->mission_statuscxx . . $ Submarine#mission_status. == MISSION_NONEcxx . . $ `src/submarine.h:108:9`!)
28 {
29 #ifdef DEBUG
30 printf("Moving to next ship that might have a mission.\n");
31 #endif
32 current_sub = current_sub->nextcxx . . $ Submarine#next.;
33 }
34 else
35 {
36 #ifdef DEBUG
37 printf("Found ship that still has a mission.\n");
38 #endif
39 found = TRUEcxx . . $ `src/map.h:10:9`!;
40 }
41 }
42
43 // mission not complete
44 if (found)
45 return MISSION_STARTEDcxx . . $ `src/mission.h:6:9`!;
46 return MISSION_SUCCESScxx . . $ `src/mission.h:7:9`!;
47 }
48
49
50
51 int Check_Findcxx . . $ Check_Find(e898ed6f8282e8).(Submarinecxx . . $ Submarine# *all_subs)
52 {
53 Submarinecxx . . $ Submarine# *player, *current_sub;
54 int signal_strength;
55
56 if (! all_subs)
57 return FALSEcxx . . $ `src/map.h:13:9`!;
58
59 player = all_subs;
60 current_sub = all_subs->nextcxx . . $ Submarine#next.;
61 while (current_sub)
62 {
63 // we are supposed to be found?
64 if (current_sub->mission_statuscxx . . $ Submarine#mission_status. == MISSION_FINDcxx . . $ `src/submarine.h:110:9`!)
65 {
66 #ifdef DEBUG
67 printf("This ship wants to be found.\n");
68 #endif
69 signal_strength = player->Can_Detectcxx . . $ Submarine#Can_Detect(e898ed6f8282e8).(current_sub);
70 // we can hear you
71 if (signal_strength == CONTACT_SOLIDcxx . . $ `src/submarine.h:47:9`!)
72 {
73 #ifdef DEBUG
74 printf("This ship has a contact level of %d\n", signal_strength);
75 #endif
76 current_sub->mission_statuscxx . . $ Submarine#mission_status. = MISSION_NONEcxx . . $ `src/submarine.h:108:9`!;
77 }
78 }
79 current_sub = current_sub->nextcxx . . $ Submarine#next.;
80 }
81
82 return TRUEcxx . . $ `src/map.h:10:9`!;
83 }
84
85
86
87 // This function checks to see if the mission depends on
88 // any ships remaining alive for a given amount of time.
89 // Any ships which have the MISSION_ALIVE flag set will
90 // have their timer reduced. If the timer hits zero (0)
91 // then we change the mission flag to be MISSION_NONE.
92 // This function returns TRUE if everything goes normally
93 // or FALSE if we encounter an error.
94 int Check_Alivecxx . . $ Check_Alive(e898ed6f8282e8).(Submarinecxx . . $ Submarine# *all_subs)
95 {
96 Submarinecxx . . $ Submarine# *current;
97
98 if (! all_subs)
99 return FALSEcxx . . $ `src/map.h:13:9`!;
100
101 current = all_subs;
102 while (current)
103 {
104 if (current->mission_statuscxx . . $ Submarine#mission_status. == MISSION_ALIVEcxx . . $ `src/submarine.h:111:9`!)
105 {
106 current->mission_timercxx . . $ Submarine#mission_timer.--;
107 if (current->mission_timercxx . . $ Submarine#mission_timer. < 1)
108 current->mission_statuscxx . . $ Submarine#mission_status. = MISSION_NONEcxx . . $ `src/submarine.h:108:9`!;
109 }
110 current = current->nextcxx . . $ Submarine#next.;
111 }
112
113 return TRUEcxx . . $ `src/map.h:10:9`!;
114 }