| 1 | /*************************************************************************** |
| 2 | submarine.h - description |
| 3 | ------------------- |
| 4 | begin : Sat Mar 16 2002 |
| 5 | copyright : (C) 2002 by Michael Bridak |
| 6 | email : [email protected] |
| 7 | $Id: submarine.h,v 1.5 2003/04/14 05:51:04 mbridak Exp $ |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | /*************************************************************************** |
| 11 | * * |
| 12 | * This program is free software; you can redistribute it and/or modify * |
| 13 | * it under the terms of the GNU General Public License as published by * |
| 14 | * the Free Software Foundation; either version 2 of the License. * |
| 15 | * . * |
| 16 | * * |
| 17 | ***************************************************************************/ |
| 18 | |
| 19 | #ifndef SUBMARINE_H |
| 20 | #define SUBMARINE_Hcxx . . $ `src/submarine.h:20:9`! |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | #include "coord.h"cxx . . $ `<file>/src/coord.h`/ |
| 24 | #include "map.h"cxx . . $ `<file>/src/map.h`/ |
| 25 | #include "stack.h"cxx . . $ `<file>/src/stack.h`/ |
| 26 | #include "towedarray.h"cxx . . $ `<file>/src/towedarray.h`/ |
| 27 | |
| 28 | #ifndef TRUEcxx . . $ `src/map.h:10:9`! |
| 29 | #define TRUE 1 |
| 30 | #endif |
| 31 | #ifndef FALSEcxx . . $ `src/map.h:13:9`! |
| 32 | #define FALSE 0 |
| 33 | #endif |
| 34 | |
| 35 | #define TYPE_SUBcxx . . $ `src/submarine.h:35:9`! 0 |
| 36 | #define TYPE_SHIPcxx . . $ `src/submarine.h:36:9`! 1 |
| 37 | #define TYPE_AIRcxx . . $ `src/submarine.h:37:9`! 2 |
| 38 | #define TYPE_TORPEDOcxx . . $ `src/submarine.h:38:9`! 3 |
| 39 | #define TYPE_NOISEMAKERcxx . . $ `src/submarine.h:39:9`! 4 |
| 40 | #define TYPE_HELICOPTERcxx . . $ `src/submarine.h:40:9`! 5 |
| 41 | |
| 42 | #define FRIENDcxx . . $ `src/submarine.h:42:9`! 1 |
| 43 | #define FOEcxx . . $ `src/submarine.h:43:9`! 0 |
| 44 | #define UNKNOWNcxx . . $ `src/submarine.h:44:9`! 2 |
| 45 | #define NEUTRALcxx . . $ `src/submarine.h:45:9`! 3 |
| 46 | |
| 47 | #define CONTACT_SOLIDcxx . . $ `src/submarine.h:47:9`! 100 |
| 48 | #define CONTACT_WEAKcxx . . $ `src/submarine.h:48:9`! 25 |
| 49 | #define CONTACT_PINGcxx . . $ `src/submarine.h:49:9`! 5 |
| 50 | #define PING_NOISEcxx . . $ `src/submarine.h:50:9`! 200 |
| 51 | |
| 52 | #define CLASS_NAME_SIZEcxx . . $ `src/submarine.h:52:9`! 32 |
| 53 | #define CLASS_TYPE_SIZEcxx . . $ `src/submarine.h:53:9`! 8 |
| 54 | #define CLASS_LOSANGELEScxx . . $ `src/submarine.h:54:9`! 1 |
| 55 | #define CLASS_AKULAcxx . . $ `src/submarine.h:55:9`! 2 |
| 56 | #define CLASS_DESTROYERcxx . . $ `src/submarine.h:56:9`! 3 |
| 57 | #define CLASS_MERCHANTcxx . . $ `src/submarine.h:57:9`! 4 |
| 58 | #define CLASS_TORPEDOcxx . . $ `src/submarine.h:58:9`! 5 |
| 59 | #define CLASS_NOISEMAKERcxx . . $ `src/submarine.h:59:9`! 6 |
| 60 | #define CLASS_TYPHOONcxx . . $ `src/submarine.h:60:9`! 7 |
| 61 | #define CLASS_NIMITZcxx . . $ `src/submarine.h:61:9`! 8 |
| 62 | #define CLASS_TBILISIcxx . . $ `src/submarine.h:62:9`! 9 |
| 63 | #define CLASS_ALPHAcxx . . $ `src/submarine.h:63:9`! 10 |
| 64 | #define CLASS_OHIOcxx . . $ `src/submarine.h:64:9`! 11 |
| 65 | #define CLASS_HELICOPTERcxx . . $ `src/submarine.h:65:9`! 12 |
| 66 | |
| 67 | // status of tubes |
| 68 | #define MAX_TUBEScxx . . $ `src/submarine.h:68:9`! 6 |
| 69 | #define TUBE_EMPTYcxx . . $ `src/submarine.h:69:9`! 0 |
| 70 | #define TUBE_TORPEDOcxx . . $ `src/submarine.h:70:9`! 1 |
| 71 | #define TUBE_NOISEMAKERcxx . . $ `src/submarine.h:71:9`! 2 |
| 72 | |
| 73 | |
| 74 | // Actions to do with tubes |
| 75 | // these have weird nmbers for legacy reasons |
| 76 | #define LOAD_TORPEDOcxx . . $ `src/submarine.h:76:17`! 66 |
| 77 | #define LOAD_NOISEMAKERcxx . . $ `src/submarine.h:77:17`! 67 |
| 78 | #define UNLOAD_TUBEcxx . . $ `src/submarine.h:78:17`! 68 |
| 79 | #define FIRE_TUBEcxx . . $ `src/submarine.h:79:17`! 69 |
| 80 | |
| 81 | // torpedo tube status codes |
| 82 | #define TUBE_ERROR_NUMBERcxx . . $ `src/submarine.h:82:9`! 1 // we were passed an invalid tube number |
| 83 | #define TUBE_ERROR_FULLcxx . . $ `src/submarine.h:83:9`! 2 // tube has something in it |
| 84 | #define TUBE_ERROR_ACTIONcxx . . $ `src/submarine.h:84:9`! 3 // we were passed an invalid action |
| 85 | #define TUBE_ERROR_NO_TORPEDOcxx . . $ `src/submarine.h:85:9`! 4 // we are out of torpedos |
| 86 | #define TUBE_ERROR_NO_NOISEcxx . . $ `src/submarine.h:86:9`! 5 // we are out of noise makers |
| 87 | #define TUBE_ERROR_TORPEDO_SUCCESScxx . . $ `src/submarine.h:87:9`! 6 // tube loaded successfully |
| 88 | #define TUBE_ERROR_NOISEMAKER_SUCCESScxx . . $ `src/submarine.h:88:9`! 7 // tube loaded successfully |
| 89 | #define TUBE_ERROR_UNLOAD_SUCCESScxx . . $ `src/submarine.h:89:9`! 8 // we cleared the tube ok |
| 90 | #define TUBE_ERROR_FIRE_FAILcxx . . $ `src/submarine.h:90:9`! 9 // could not fire torpedo |
| 91 | #define TUBE_ERROR_FIRE_SUCCESScxx . . $ `src/submarine.h:91:9`! 10 // we fired a torpedo |
| 92 | #define TUBE_ERROR_FIRE_NOISEMAKERcxx . . $ `src/submarine.h:92:9`! 11 // we fired a noisemaker |
| 93 | |
| 94 | #define TORPEDO_FUELcxx . . $ `src/submarine.h:94:9`! 600 |
| 95 | #define HITTING_RANGEcxx . . $ `src/submarine.h:95:9`! 50 |
| 96 | #define HITTING_DEPTHcxx . . $ `src/submarine.h:96:9`! 25 |
| 97 | #define OUT_OF_FUELcxx . . $ `src/submarine.h:97:9`! 1 |
| 98 | #define HIT_TARGETcxx . . $ `src/submarine.h:98:9`! 2 |
| 99 | #define STATUS_OKcxx . . $ `src/submarine.h:99:9`! 3 |
| 100 | |
| 101 | #define DAMAGE_OKcxx . . $ `src/submarine.h:101:9`! 1 |
| 102 | #define DAMAGE_SINKcxx . . $ `src/submarine.h:102:9`! 2 |
| 103 | |
| 104 | #define CHANCE_COURSEcxx . . $ `src/submarine.h:104:9`! 1000 |
| 105 | #define RUDDER_CHANGEcxx . . $ `src/submarine.h:105:9`! 0.025 |
| 106 | #define PLANES_CHANGEcxx . . $ `src/submarine.h:106:9`! 0.2 // originally around 0.185 |
| 107 | |
| 108 | #define MISSION_NONEcxx . . $ `src/submarine.h:108:9`! 0 |
| 109 | #define MISSION_SINKcxx . . $ `src/submarine.h:109:9`! 1 |
| 110 | #define MISSION_FINDcxx . . $ `src/submarine.h:110:9`! 2 |
| 111 | #define MISSION_ALIVEcxx . . $ `src/submarine.h:111:9`! 3 |
| 112 | |
| 113 | #define YARDS_TO_MILEScxx . . $ `src/submarine.h:113:9`! 0.000568 |
| 114 | #define MILES_TO_YARDScxx . . $ `src/submarine.h:114:9`! 1760 |
| 115 | #define PERISCOPE_DEPTHcxx . . $ `src/submarine.h:115:9`! 50 |
| 116 | |
| 117 | #define MAX_TORPEDOES_FIREDcxx . . $ `src/submarine.h:117:9`! 1 |
| 118 | #define MAX_NOISEMAKERS_FIREDcxx . . $ `src/submarine.h:118:9`! 1 |
| 119 | #define MAX_PLAYER_WEAPONScxx . . $ `src/submarine.h:119:9`! 6 |
| 120 | #define MAX_TORPEDO_RANGEcxx . . $ `src/submarine.h:120:9`! 8 |
| 121 | #define TORPEDO_RANGE_ATTACKcxx . . $ `src/submarine.h:121:9`! 4 |
| 122 | #define TORPEDO_RANGE_PASSIVEcxx . . $ `src/submarine.h:122:9`! 3 |
| 123 | |
| 124 | #define DISTRACTED_CHANCEcxx . . $ `src/submarine.h:124:9`! 4 // 1 in 4 chance a torpedo will chase noisemaker |
| 125 | |
| 126 | // types of behaviour |
| 127 | #define MOOD_ATTACKcxx . . $ `src/submarine.h:127:9`! 1 |
| 128 | #define MOOD_PASSIVEcxx . . $ `src/submarine.h:128:9`! 2 |
| 129 | #define MOOD_CONVOYcxx . . $ `src/submarine.h:129:9`! 3 |
| 130 | |
| 131 | #define CONVOY_CHANGE_COURSEcxx . . $ `src/submarine.h:131:9`! 1200 |
| 132 | |
| 133 | // radio messages for surface ships |
| 134 | #define RADIO_NONEcxx . . $ `src/submarine.h:134:9`! 0 |
| 135 | #define RADIO_UNDER_ATTACKcxx . . $ `src/submarine.h:135:9`! 1 |
| 136 | #define RADIO_HEAR_TORPEDOcxx . . $ `src/submarine.h:136:9`! 2 |
| 137 | // maybe add impending attack, detected sub, reform convoy... |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | /** |
| 143 | *@author Michael Bridak |
| 144 | */ |
| 145 | |
| 146 | typedef structcxx . . $ $anonymous_type_8e0798e5786ef39c_0# |
| 147 | { |
| 148 | void *subcxx . . $ $anonymous_type_8e0798e5786ef39c_0#sub.; |
| 149 | void *nextcxx . . $ $anonymous_type_8e0798e5786ef39c_0#next.; |
| 150 | int contact_strengthcxx . . $ $anonymous_type_8e0798e5786ef39c_0#contact_strength.; |
| 151 | } Targetcxx . . $ Target#; |
| 152 | |
| 153 | |
| 154 | class Submarinecxx . . $ Submarine# : public Coordcxx . . $ Coord#, public Stackcxx . . $ Stack# { |
| 155 | public: |
| 156 | float NauticalMilescxx . . $ Submarine#NauticalMiles.; |
| 157 | float HisPassiveSonarCrosssectioncxx . . $ Submarine#HisPassiveSonarCrosssection.; |
| 158 | float EffectiveTargetSpeedcxx . . $ Submarine#EffectiveTargetSpeed.; |
| 159 | float AmbientNoisecxx . . $ Submarine#AmbientNoise.; |
| 160 | float OwnShipNoisecxx . . $ Submarine#OwnShipNoise.; |
| 161 | float flowandambientnoisecxx . . $ Submarine#flowandambientnoise.; |
| 162 | float TotalNoisecxx . . $ Submarine#TotalNoise.; |
| 163 | float TargetNoisecxx . . $ Submarine#TargetNoise.; |
| 164 | float Gbcxx . . $ Submarine#Gb.; |
| 165 | float Lbpcxx . . $ Submarine#Lbp.; |
| 166 | float NoiseFromSpeedcxx . . $ Submarine#NoiseFromSpeed.; |
| 167 | float BasisNoiseLevelcxx . . $ Submarine#BasisNoiseLevel.; |
| 168 | float valuecxx . . $ Submarine#value.; |
| 169 | float SeaStatecxx . . $ Submarine#SeaState.; // Anyone want to model the weather. |
| 170 | int current_targetcxx . . $ Submarine#current_target.; // who are we tracking? |
| 171 | int Activecxx . . $ Submarine#Active.; /*Flag to see if ship is in the world.*/ |
| 172 | int ShipTypecxx . . $ Submarine#ShipType.; /*SubSurface, Surface, Air */ |
| 173 | int ShipClasscxx . . $ Submarine#ShipClass.; // specific type (Los Angels, Akula, etc) |
| 174 | char ClassNamecxx . . $ Submarine#ClassName.[CLASS_NAME_SIZEcxx . . $ `src/submarine.h:52:9`!]; |
| 175 | char ClassTypecxx . . $ Submarine#ClassType.[CLASS_TYPE_SIZEcxx . . $ `src/submarine.h:53:9`!]; |
| 176 | int Friendcxx . . $ Submarine#Friend.; /*Flag to mark if ship is a friend/foe/neither*/ |
| 177 | float Depthcxx . . $ Submarine#Depth.; /*How deep are we?*/ |
| 178 | int DesiredDepthcxx . . $ Submarine#DesiredDepth.; /*You want to go how deep!*/ |
| 179 | int MaxDepthcxx . . $ Submarine#MaxDepth.; /*Why is my hull crushing!*/ |
| 180 | int DesiredSpeedcxx . . $ Submarine#DesiredSpeed.; /*Scotty warp speed!*/ |
| 181 | int MaxSpeedcxx . . $ Submarine#MaxSpeed.; /*Captin I've given her all she's got!*/ |
| 182 | int MinSpeedcxx . . $ Submarine#MinSpeed.; /*You want to go how fast in reverse!?*/ |
| 183 | int DesiredHeadingcxx . . $ Submarine#DesiredHeading.; |
| 184 | int Ruddercxx . . $ Submarine#Rudder.; /*bend me and she will turn*/ |
| 185 | int TorpedosOnBoardcxx . . $ Submarine#TorpedosOnBoard.; /*Where are all the fish!*/ |
| 186 | int NoiseMakerscxx . . $ Submarine#NoiseMakers.; // to destract the torpedos |
| 187 | int CavitationFlagcxx . . $ Submarine#CavitationFlag.; |
| 188 | int BaseNoisecxx . . $ Submarine#BaseNoise.; /*how noisey are we just sittin' here*/ |
| 189 | float PSCScxx . . $ Submarine#PSCS.; /*Passive Sonar Crosssection*/ |
| 190 | float RadiatedNoisecxx . . $ Submarine#RadiatedNoise(9b8c9e39889c762c).(); /*Tell 'em how loud we are.*/ |
| 191 | void CheckForCavitationcxx . . $ Submarine#CheckForCavitation(49f6e7a06ebc5aa8).(); /*self explanitory */ |
| 192 | void Handelingcxx . . $ Submarine#Handeling(49f6e7a06ebc5aa8).(); /*Turn Left/Right go Up/Down Etc...*/ |
| 193 | float CheckNegSpeedcxx . . $ Submarine#CheckNegSpeed(fbcf3211dfe1bfd1).(float); /*if Speed is negative return inverse value*/ |
| 194 | double DistanceToTargetcxx . . $ Submarine#DistanceToTarget(2de0d0e522051339).(Submarinecxx . . $ Submarine# *Target); |
| 195 | double BearingToTargetcxx . . $ Submarine#BearingToTarget(2de0d0e522051339).(Submarinecxx . . $ Submarine# *Target); |
| 196 | double BearingToOrigincxx . . $ Submarine#BearingToOrigin(2de0d0e522051339).(Submarinecxx . . $ Submarine# *Target); |
| 197 | float DEAnglecxx . . $ Submarine#DEAngle(9d7e1bc3065e2a78).(Submarinecxx . . $ Submarine# *Target); |
| 198 | int hull_strengthcxx . . $ Submarine#hull_strength.; |
| 199 | int mission_statuscxx . . $ Submarine#mission_status.; |
| 200 | int mission_timercxx . . $ Submarine#mission_timer.; |
| 201 | int has_sonarcxx . . $ Submarine#has_sonar.; |
| 202 | int moodcxx . . $ Submarine#mood.; |
| 203 | int convoy_course_changecxx . . $ Submarine#convoy_course_change.; |
| 204 | int radio_messagecxx . . $ Submarine#radio_message.; |
| 205 | int torpedo_tubecxx . . $ Submarine#torpedo_tube.[MAX_TUBEScxx . . $ `src/submarine.h:68:9`!]; |
| 206 | int pingingcxx . . $ Submarine#pinging.; // are we using active sonar? |
| 207 | int using_radarcxx . . $ Submarine#using_radar.; |
| 208 | MAPcxx . . $ MAP# *mapcxx . . $ Submarine#map.; |
| 209 | |
| 210 | Submarinecxx . . $ Submarine# *nextcxx . . $ Submarine#next.; // also for torpedos, though could be used |
| 211 | // later for ships |
| 212 | Submarinecxx . . $ Submarine# *targetcxx . . $ Submarine#target.; // for torpedoes |
| 213 | Targetcxx . . $ Target# *last_targetcxx . . $ Submarine#last_target.; |
| 214 | Submarinecxx . . $ Submarine# *ownercxx . . $ Submarine#owner.; // torpedoes are owned by ships/subs |
| 215 | int fuel_remainingcxx . . $ Submarine#fuel_remaining.; // mostly for torpedos, |
| 216 | // but maybe for electric subs later |
| 217 | int origin_xcxx . . $ Submarine#origin_x., origin_ycxx . . $ Submarine#origin_y.; // where did this torp come from? |
| 218 | |
| 219 | Submarinecxx . . $ Submarine#Submarine(49f6e7a06ebc5aa8).(); |
| 220 | ~cxx . . $ Submarine#`~Submarine`(49f6e7a06ebc5aa8).Submarinecxx . . $ Submarine#(); |
| 221 | void Initcxx . . $ Submarine#Init(49f6e7a06ebc5aa8).(); |
| 222 | |
| 223 | // We should be able to track targets |
| 224 | Targetcxx . . $ Target# *targetscxx . . $ Submarine#targets.; |
| 225 | int Add_Targetcxx . . $ Submarine#Add_Target(fc20a4b472e56652).(Submarinecxx . . $ Submarine# *new_sub, float contact_strength); |
| 226 | void Remove_Targetcxx . . $ Submarine#Remove_Target(a9ab5cc9dc811b12).(Submarinecxx . . $ Submarine# *old_sub); |
| 227 | void Cancel_Targetcxx . . $ Submarine#Cancel_Target(a9ab5cc9dc811b12).(Submarinecxx . . $ Submarine# *old_sub); |
| 228 | int Can_Detectcxx . . $ Submarine#Can_Detect(e898ed6f8282e8).(Submarinecxx . . $ Submarine# *a_sub); |
| 229 | |
| 230 | // returns target index or -1 if none is available |
| 231 | Submarinecxx . . $ Submarine# *Next_Targetcxx . . $ Submarine#Next_Target(5a8a75acd7038d8b).(); |
| 232 | |
| 233 | // Load information on this type of ship/sub |
| 234 | int Load_Classcxx . . $ Submarine#Load_Class(1ef8e6ec083aabb9).(char *from_file); |
| 235 | int Load_Missioncxx . . $ Submarine#Load_Mission(89bc1efcdac0ca22).(FILE *from_file); |
| 236 | int Use_Tubecxx . . $ Submarine#Use_Tube(9b79fb6aee4c0440).(int action, int tube_number); |
| 237 | |
| 238 | Submarinecxx . . $ Submarine# *Fire_Tubecxx . . $ Submarine#Fire_Tube(7e9c5f383c561fca).(Submarinecxx . . $ Submarine# *target, char *ship_file); |
| 239 | int Can_Hearcxx . . $ Submarine#Can_Hear(e898ed6f8282e8).(Submarinecxx . . $ Submarine# *target); |
| 240 | int Torpedo_AIcxx . . $ Submarine#Torpedo_AI(e898ed6f8282e8).(Submarinecxx . . $ Submarine# *all_subs); |
| 241 | // figure out what to do with surface ships |
| 242 | // Submarine *Ship_AI(Submarine *all_ships, Submarine *all_torpedoes); |
| 243 | // like ship AI in 3D |
| 244 | Submarinecxx . . $ Submarine# *Sub_AIcxx . . $ Submarine#Sub_AI(3be2d61bc00ebf6b).(Submarinecxx . . $ Submarine# *all_ships, Submarinecxx . . $ Submarine# *all_torpedoes, void *helicopters); |
| 245 | int Check_Statuscxx . . $ Submarine#Check_Status(b126dc7c1de90089).(); // see if our torpedo is ok |
| 246 | int Take_Damagecxx . . $ Submarine#Take_Damage(b126dc7c1de90089).(); // we were hit! |
| 247 | int Count_Torpedoescxx . . $ Submarine#Count_Torpedoes(e898ed6f8282e8).(Submarinecxx . . $ Submarine# *all_torpedoes); // how many have I fired? |
| 248 | int Count_Noisemakerscxx . . $ Submarine#Count_Noisemakers(e898ed6f8282e8).(Submarinecxx . . $ Submarine# *all_noise); // how many have I launched? |
| 249 | Submarinecxx . . $ Submarine# *Have_Enemy_Targetcxx . . $ Submarine#Have_Enemy_Target(9c4f5e11a658b20d).(Submarinecxx . . $ Submarine# *all_ships); |
| 250 | Submarinecxx . . $ Submarine# *Launch_Noisemakercxx . . $ Submarine#Launch_Noisemaker(d62bab4205bed956).(Submarinecxx . . $ Submarine# *all_torpedoes, Submarinecxx . . $ Submarine# *chased_by); // AI function |
| 251 | int Is_Distracted_By_Noisemakercxx . . $ Submarine#Is_Distracted_By_Noisemaker(e898ed6f8282e8).(Submarinecxx . . $ Submarine# *noisemaker); // is this torpedo distracted? |
| 252 | int Radio_Signalcxx . . $ Submarine#Radio_Signal(8e102eb2bbf433ac).(Submarinecxx . . $ Submarine# *all_ships, int my_signal); |
| 253 | int Send_Pingcxx . . $ Submarine#Send_Ping(e898ed6f8282e8).(Submarinecxx . . $ Submarine# *all_ships); |
| 254 | int InBafflescxx . . $ Submarine#InBaffles(9887e4a8163b3a3f).(Submarinecxx . . $ Submarine# *target, int sensor, TowedArraycxx . . $ TowedArray# *TB16); |
| 255 | }; |
| 256 | |
| 257 | #endif |
| 258 |