| 1 | #cxx . . $ `<file>/src/map.cpp`/include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include "map.h"cxx . . $ `<file>/src/map.h`/ |
| 4 | |
| 5 | |
| 6 | MAPcxx . . $ MAP#::MAPcxx . . $ MAP#MAP(49f6e7a06ebc5aa8).() |
| 7 | { |
| 8 | Initcxx . . $ MAP#Init(b126dc7c1de90089).(); |
| 9 | } |
| 10 | |
| 11 | |
| 12 | |
| 13 | MAPcxx . . $ MAP#::~cxx . . $ MAP#`~MAP`(ced63f7c635d850d).MAPcxx . . $ MAP#() |
| 14 | { |
| 15 | |
| 16 | } |
| 17 | |
| 18 | |
| 19 | |
| 20 | int MAPcxx . . $ MAP#::Initcxx . . $ MAP#Init(b126dc7c1de90089).() |
| 21 | { |
| 22 | int status; |
| 23 | int index; |
| 24 | |
| 25 | // init stuff ahead of time |
| 26 | for (index = 0; index < MAX_THERMALScxx . . $ `src/map.h:18:9`!; index++) |
| 27 | thermalscxx . . $ MAP#thermals.[index] = 0; |
| 28 | |
| 29 | status = Create_Thermal_Layerscxx . . $ MAP#Create_Thermal_Layers(7864480464b09eea).(MAX_THERMALScxx . . $ `src/map.h:18:9`!); |
| 30 | return status; |
| 31 | } |
| 32 | |
| 33 | |
| 34 | |
| 35 | // This function creates thermal layers spaced (more or less) |
| 36 | // eveningly. The function returns the number of thermals created. |
| 37 | int MAPcxx . . $ MAP#::Create_Thermal_Layerscxx . . $ MAP#Create_Thermal_Layers(7864480464b09eea).(int how_many) |
| 38 | { |
| 39 | int base_range; |
| 40 | int current_range; |
| 41 | int index; |
| 42 | |
| 43 | base_range = MAX_THERMAL_DEPTHcxx . . $ `src/map.h:19:9`! / how_many; |
| 44 | current_range = 0; |
| 45 | index = 0; |
| 46 | while ( (index < MAX_THERMALScxx . . $ `src/map.h:18:9`!) && (index < how_many) ) |
| 47 | { |
| 48 | current_range += base_range; |
| 49 | thermalscxx . . $ MAP#thermals.[index] = current_range + ( randcxx . . $ rand(9efc7249d839d30e).() % 150 ) - 75; |
| 50 | index++; |
| 51 | } |
| 52 | |
| 53 | return index; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | // At this point the ocean depth is the same everywhere, so |
| 58 | // we ignore the passed coordinaes and just return MAX_DEPTH |
| 59 | int MAPcxx . . $ MAP#::Get_Ocean_Depthcxx . . $ MAP#Get_Ocean_Depth(9b79fb6aee4c0440).(int x, int y) |
| 60 | { |
| 61 | return MAX_DEPTHcxx . . $ `src/map.h:16:9`!; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | |
| 66 | // This function returns the number of thermal layers |
| 67 | // between depth1 and depth2 |
| 68 | // If no thermals exist then the function returns zero. |
| 69 | int MAPcxx . . $ MAP#::Thermals_Betweencxx . . $ MAP#Thermals_Between(9b79fb6aee4c0440).(int depth_1, int depth_2) |
| 70 | { |
| 71 | int start_point, end_point; |
| 72 | int index, thermal_count; |
| 73 | |
| 74 | // if depths are the same, just return |
| 75 | if (depth_1 == depth_2) |
| 76 | return 0; |
| 77 | |
| 78 | // we need to make sure start_point is the higher depth |
| 79 | if (depth_1 <= depth_2) |
| 80 | { |
| 81 | start_point = depth_1; |
| 82 | end_point = depth_2; |
| 83 | } |
| 84 | else |
| 85 | { |
| 86 | start_point = depth_2; |
| 87 | end_point = depth_1; |
| 88 | } |
| 89 | |
| 90 | // move through each thermal layer and see if it lies between |
| 91 | // the two depths. |
| 92 | index = thermal_count = 0; |
| 93 | while (index < MAX_THERMALScxx . . $ `src/map.h:18:9`!) |
| 94 | { |
| 95 | if ( (start_point < thermalscxx . . $ MAP#thermals.[index]) && (thermalscxx . . $ MAP#thermals.[index] < end_point) ) |
| 96 | thermal_count++; |
| 97 | index++; |
| 98 | } |
| 99 | |
| 100 | return thermal_count; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | /* |
| 105 | This function finds the next themral above the current depth. If |
| 106 | no thermal lies above this position then we return "from_depth". |
| 107 | */ |
| 108 | int MAPcxx . . $ MAP#::Next_Upcxx . . $ MAP#Next_Up(7864480464b09eea).(int from_depth) |
| 109 | { |
| 110 | int index = MAX_THERMALScxx . . $ `src/map.h:18:9`! - 1; |
| 111 | int found = FALSEcxx . . $ `src/map.h:13:9`!; |
| 112 | |
| 113 | while ( (!found) && (index >= 0) ) |
| 114 | { |
| 115 | if ( (thermalscxx . . $ MAP#thermals.[index] > 0) && (thermalscxx . . $ MAP#thermals.[index] < from_depth) ) |
| 116 | found = TRUEcxx . . $ `src/map.h:10:9`!; |
| 117 | else |
| 118 | index--; |
| 119 | } |
| 120 | if (found) |
| 121 | return thermalscxx . . $ MAP#thermals.[index]; |
| 122 | else |
| 123 | return from_depth; |
| 124 | } |
| 125 | |
| 126 | |
| 127 | /* |
| 128 | This function finds the next themral below the current depth. If |
| 129 | no thermal lies below this position then we return "from_depth". |
| 130 | */ |
| 131 | int MAPcxx . . $ MAP#::Next_Downcxx . . $ MAP#Next_Down(7864480464b09eea).(int from_depth) |
| 132 | { |
| 133 | int index = 0; |
| 134 | int found = FALSEcxx . . $ `src/map.h:13:9`!; |
| 135 | |
| 136 | while ( (!found) && (index < MAX_THERMALScxx . . $ `src/map.h:18:9`!) ) |
| 137 | { |
| 138 | if ( (thermalscxx . . $ MAP#thermals.[index] > 0) && (thermalscxx . . $ MAP#thermals.[index] > from_depth) ) |
| 139 | found = TRUEcxx . . $ `src/map.h:10:9`!; |
| 140 | else |
| 141 | index++; |
| 142 | } |
| 143 | if (found) |
| 144 | return thermalscxx . . $ MAP#thermals.[index]; |
| 145 | else |
| 146 | return from_depth; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | #ifdef DEBUGMAP |
| 156 | void MAP::Test_Map() |
| 157 | { |
| 158 | int index; |
| 159 | |
| 160 | for (index = 0; index < MAX_THERMALS; index++) |
| 161 | printf("Map termal %d: %d\n", index, thermals[index]); |
| 162 | index = Thermals_Between(MIN_DEPTH, MAX_DEPTH); |
| 163 | printf("Thermals between %d and %d: %d\n", MIN_DEPTH, MAX_DEPTH, index); |
| 164 | index = Thermals_Between(MAX_DEPTH, MIN_DEPTH); |
| 165 | printf("Thermals between %d and %d: %d\n", MAX_DEPTH, MIN_DEPTH, index); |
| 166 | } |
| 167 | |
| 168 | #endif |