DRIVE.CPP 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  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. /* $Header: /CounterStrike/DRIVE.CPP 1 3/03/97 10:24a Joe_bostic $ */
  19. /***********************************************************************************************
  20. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : DRIVE.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : April 22, 1994 *
  30. * *
  31. * Last Update : October 31, 1996 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * DriveClass::AI -- Processes unit movement and rotation. *
  36. * DriveClass::Approach_Target -- Handles approaching the target in order to attack it. *
  37. * DriveClass::Assign_Destination -- Set the unit's NavCom. *
  38. * DriveClass::Class_Of -- Fetches a reference to the class type for this object. *
  39. * DriveClass::Debug_Dump -- Displays status information to monochrome screen. *
  40. * DriveClass::Do_Turn -- Tries to turn the vehicle to the specified direction. *
  41. * DriveClass::DriveClass -- Constructor for drive class object. *
  42. * DriveClass::Fixup_Path -- Adds smooth start path to normal movement path. *
  43. * DriveClass::Force_Track -- Forces the unit to use the indicated track. *
  44. * DriveClass::Lay_Track -- Handles track laying logic for the unit. *
  45. * DriveClass::Limbo -- Prepares vehicle and then limbos it. *
  46. * DriveClass::Mark_Track -- Marks the midpoint of the track as occupied. *
  47. * DriveClass::Ok_To_Move -- Checks to see if this object can begin moving. *
  48. * DriveClass::Per_Cell_Process -- Handles when unit finishes movement into a cell. *
  49. * DriveClass::Response_Attack -- Voice feedback when ordering the unit to attack a target. *
  50. * DriveClass::Response_Move -- Voice feedback when ordering the unit to move. *
  51. * DriveClass::Response_Select -- Voice feedback when selecting the unit. *
  52. * DriveClass::Scatter -- Causes the unit to travel to a nearby safe cell. *
  53. * DriveClass::Smooth_Turn -- Handles the low level coord calc for smooth turn logic. *
  54. * DriveClass::Start_Of_Move -- Tries to get a unit to advance toward cell. *
  55. * DriveClass::Stop_Driver -- Handles removing occupation bits when driving stops. *
  56. * DriveClass::Teleport_To -- Teleport object to specified location. *
  57. * DriveClass::While_Moving -- Processes unit movement. *
  58. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  59. #include "function.h"
  60. #ifdef NEVER
  61. void test(void)
  62. {
  63. enum nums {one, two, three};
  64. nums x;
  65. nums *ptr;
  66. ptr = &x;
  67. }
  68. #endif
  69. /***********************************************************************************************
  70. * DriveClass::Response_Select -- Voice feedback when selecting the unit. *
  71. * *
  72. * This is the voice to play when the unit is selected. *
  73. * *
  74. * INPUT: none *
  75. * *
  76. * OUTPUT: none *
  77. * *
  78. * WARNINGS: none *
  79. * *
  80. * HISTORY: *
  81. * 12/30/1994 JLB : Created. *
  82. *=============================================================================================*/
  83. void DriveClass::Response_Select(void)
  84. {
  85. assert(IsActive);
  86. static VocType _response[] = {
  87. VOC_VEHIC,
  88. VOC_REPORT,
  89. VOC_YESSIR,
  90. VOC_YESSIR,
  91. VOC_YESSIR,
  92. VOC_AWAIT
  93. };
  94. VocType response = _response[Sim_Random_Pick(0, ARRAY_SIZE(_response)-1)];
  95. if (AllowVoice) {
  96. Sound_Effect(response, fixed(1), -(ID+1));
  97. }
  98. }
  99. /***********************************************************************************************
  100. * DriveClass::Response_Move -- Voice feedback when ordering the unit to move. *
  101. * *
  102. * This plays the audio feedback when ordering this unit to move to a new destination. *
  103. * *
  104. * INPUT: none *
  105. * *
  106. * OUTPUT: none *
  107. * *
  108. * WARNINGS: none *
  109. * *
  110. * HISTORY: *
  111. * 12/30/1994 JLB : Created. *
  112. *=============================================================================================*/
  113. void DriveClass::Response_Move(void)
  114. {
  115. assert(IsActive);
  116. static VocType _response[] = {
  117. VOC_ACKNOWL,
  118. VOC_AFFIRM,
  119. };
  120. VocType response = _response[Sim_Random_Pick(0, ARRAY_SIZE(_response)-1)];
  121. if (AllowVoice) {
  122. Sound_Effect(response, fixed(1), -(ID+1));
  123. }
  124. }
  125. /***********************************************************************************************
  126. * DriveClass::Response_Attack -- Voice feedback when ordering the unit to attack a target. *
  127. * *
  128. * This plays the audio feedback when ordering this unit to attack. *
  129. * *
  130. * INPUT: none *
  131. * *
  132. * OUTPUT: none *
  133. * *
  134. * WARNINGS: none *
  135. * *
  136. * HISTORY: *
  137. * 12/30/1994 JLB : Created. *
  138. *=============================================================================================*/
  139. void DriveClass::Response_Attack(void)
  140. {
  141. assert(IsActive);
  142. static VocType _response[] = {
  143. VOC_AFFIRM,
  144. VOC_ACKNOWL
  145. };
  146. VocType response = _response[Sim_Random_Pick(0, ARRAY_SIZE(_response)-1)];
  147. if (AllowVoice) {
  148. Sound_Effect(response, fixed(1), -(ID+1));
  149. }
  150. }
  151. /***********************************************************************************************
  152. * DriveClass::Scatter -- Causes the unit to travel to a nearby safe cell. *
  153. * *
  154. * This routine is called when the unit discovers that it should get out of the "hot seat" *
  155. * and move to an adjacent cell. Since the safety of the adjacent cell is not determined *
  156. * before the move begins, it will appear that the unit is just scattering (which it *
  157. * should). *
  158. * *
  159. * INPUT: threat -- The coordinate of the source of the threat. The unit will try to move *
  160. * roughly away from the threat. *
  161. * *
  162. * forced -- The threat is real and a serious effort to scatter should be made. *
  163. * *
  164. * nokidding-- The scatter should affect the player's infantry even if it otherwise *
  165. * wouldn't have. *
  166. * *
  167. * OUTPUT: none *
  168. * *
  169. * WARNINGS: none *
  170. * *
  171. * HISTORY: *
  172. * 09/25/1994 JLB : Created. *
  173. * 09/27/1995 JLB : Revised to never scatter if already moving. *
  174. * 07/09/1996 JLB : Moved to DriveClass so that ships will scatter too. *
  175. * 08/02/1996 JLB : Added the "nokidding" parameter. *
  176. *=============================================================================================*/
  177. void DriveClass::Scatter(COORDINATE threat, bool forced, bool nokidding)
  178. {
  179. assert(IsActive);
  180. /*
  181. ** Certain missions prevent scattering regardless of whether it would be
  182. ** a good idea or not.
  183. */
  184. if (MissionControl[Mission].IsParalyzed) return;
  185. if ((What_Am_I() != RTTI_UNIT || !((UnitClass *)this)->IsDumping) && (!Target_Legal(NavCom) || (nokidding && !IsRotating))) {
  186. if (!Target_Legal(TarCom) || forced || Random_Pick(1, 4) == 1) {
  187. FacingType toface;
  188. FacingType newface;
  189. CELL newcell;
  190. if (threat != 0) {
  191. toface = Dir_Facing(Direction8(threat, Coord));
  192. toface = toface + FacingType(Random_Pick(0, 2)-1);
  193. } else {
  194. toface = Dir_Facing(PrimaryFacing.Current());
  195. toface = toface + FacingType(Random_Pick(0, 2)-1);
  196. }
  197. for (FacingType face = FACING_N; face < FACING_COUNT; face++) {
  198. newface = toface + face;
  199. newcell = Adjacent_Cell(Coord_Cell(Coord), newface);
  200. if (Map.In_Radar(newcell) && Can_Enter_Cell(newcell) == MOVE_OK) {
  201. Assign_Destination(::As_Target(newcell));
  202. }
  203. }
  204. }
  205. }
  206. }
  207. /***********************************************************************************************
  208. * DriveClass::Limbo -- Prepares vehicle and then limbos it. *
  209. * *
  210. * This routine removes the occupation bits for the vehicle and also handles cleaning up *
  211. * any vehicle reservation bits. After this, it then proceeds with limboing the unit. *
  212. * *
  213. * INPUT: none *
  214. * *
  215. * OUTPUT: bool; Was the vehicle limboed? *
  216. * *
  217. * WARNINGS: none *
  218. * *
  219. * HISTORY: *
  220. * 12/22/1994 JLB : Created. *
  221. *=============================================================================================*/
  222. bool DriveClass::Limbo(void)
  223. {
  224. if (!IsInLimbo) {
  225. Stop_Driver();
  226. TrackNumber = -1;
  227. }
  228. return(FootClass::Limbo());
  229. }
  230. /***********************************************************************************************
  231. * DriveClass::Stop_Driver -- Handles removing occupation bits when driving stops. *
  232. * *
  233. * This routine will remove the "reservation" flag (if present) when the vehicle is *
  234. * required to stop movement. *
  235. * *
  236. * INPUT: none *
  237. * *
  238. * OUTPUT: bool; Was the vehicle stopped? *
  239. * *
  240. * WARNINGS: none *
  241. * *
  242. * HISTORY: *
  243. * 12/22/1994 JLB : Created. *
  244. *=============================================================================================*/
  245. bool DriveClass::Stop_Driver(void)
  246. {
  247. assert(IsActive);
  248. /*
  249. ** We only need to do something if the vehicle is actually going
  250. ** somewhere.
  251. */
  252. if (Head_To_Coord()) {
  253. /*
  254. ** Safe off whether the vehicle is down or not so we know whether
  255. ** we have to put it back down.
  256. */
  257. int temp = IsDown;
  258. /*
  259. ** If the vehicle is down, pick it up so it doesn't interfere with
  260. ** our flags.
  261. */
  262. if (temp) {
  263. Mark(MARK_UP);
  264. }
  265. /*
  266. ** Call the drive class function which will let us release the
  267. ** reserved track.
  268. */
  269. Mark_Track(Head_To_Coord(), MARK_UP);
  270. /*
  271. ** If it was down it should be down when we are done.
  272. */
  273. if (temp) {
  274. Mark(MARK_DOWN);
  275. }
  276. }
  277. return(FootClass::Stop_Driver());
  278. }
  279. /***********************************************************************************************
  280. * DriveClass::Do_Turn -- Tries to turn the vehicle to the specified direction. *
  281. * *
  282. * This routine will set the vehicle to rotate to the direction specified. For tracked *
  283. * vehicles, it is just a simple rotation. For wheeled vehicles, it performs a series *
  284. * of short drives (three point turn) to face the desired direction. *
  285. * *
  286. * INPUT: dir -- The direction that this vehicle should face. *
  287. * *
  288. * OUTPUT: none *
  289. * *
  290. * WARNINGS: none *
  291. * *
  292. * HISTORY: *
  293. * 05/29/1995 JLB : Created. *
  294. *=============================================================================================*/
  295. void DriveClass::Do_Turn(DirType dir)
  296. {
  297. assert(IsActive);
  298. if (dir != PrimaryFacing) {
  299. #ifdef TOFIX
  300. /*
  301. ** Special rotation track is needed for units that
  302. ** cannot rotate in place.
  303. */
  304. if (Special.IsThreePoint && TrackNumber == -1 && Techno_Type_Class()->Speed == SPEED_WHEEL) {
  305. int facediff; // Signed difference between current and desired facing.
  306. FacingType face; // Current facing (ordinal value).
  307. facediff = PrimaryFacing.Difference(dir) >> 5;
  308. facediff = Bound(facediff, -2, 2);
  309. if (facediff) {
  310. face = Dir_Facing(PrimaryFacing);
  311. IsOnShortTrack = true;
  312. Force_Track(face*FACING_COUNT + (face + facediff), Coord);
  313. Path[0] = FACING_NONE;
  314. Set_Speed(0xFF); // Full speed.
  315. }
  316. } else {
  317. PrimaryFacing.Set_Desired(dir);
  318. }
  319. #else
  320. PrimaryFacing.Set_Desired(dir);
  321. // IsRotating = true;
  322. #endif
  323. }
  324. }
  325. /***********************************************************************************************
  326. * DriveClass::Teleport_To -- Teleport object to specified location. *
  327. * *
  328. * This will teleport the object to the specified location or as close as possible to it *
  329. * if the destination is blocked. *
  330. * *
  331. * INPUT: cell -- The desired destination cell to teleport to. *
  332. * *
  333. * OUTPUT: bool; Was the teleport successful? *
  334. * *
  335. * WARNINGS: All current activity of this object will be terminated by the teleport. It will *
  336. * arrive at the destination in static guard mode. *
  337. * *
  338. * HISTORY: *
  339. * 10/21/1996 JLB : Created. *
  340. * 10/31/1996 JLB : Handles flag teleport case. *
  341. *=============================================================================================*/
  342. bool DriveClass::Teleport_To(CELL cell)
  343. {
  344. /*
  345. ** All cargo gets destroyed.
  346. */
  347. if (Rule.IsChronoKill) {
  348. Kill_Cargo(NULL);
  349. }
  350. Stop_Driver();
  351. Force_Track(-1, 0);
  352. PrimaryFacing.Set_Current(PrimaryFacing.Desired());
  353. Transmit_Message(RADIO_OVER_OUT);
  354. Assign_Destination(TARGET_NONE);
  355. Assign_Target(TARGET_NONE);
  356. Assign_Mission(MISSION_NONE);
  357. Commence();
  358. Mark(MARK_UP);
  359. /*
  360. ** A teleported unit will drop the flag right where it's at.
  361. */
  362. if (What_Am_I() == RTTI_UNIT && ((UnitClass *)this)->Flagged != HOUSE_NONE) {
  363. HouseClass::As_Pointer(((UnitClass *)this)->Flagged)->Flag_Attach(Coord_Cell(Coord));
  364. }
  365. if (Can_Enter_Cell(cell) != MOVE_OK) {
  366. cell = Map.Nearby_Location(cell, Techno_Type_Class()->Speed);
  367. }
  368. Coord = Cell_Coord(cell);
  369. Mark(MARK_DOWN);
  370. return(true);
  371. }
  372. /***********************************************************************************************
  373. * DriveClass::Force_Track -- Forces the unit to use the indicated track. *
  374. * *
  375. * This override (nuclear bomb) style routine is to be used when a unit needs to start *
  376. * on a movement track but is outside the normal movement system. This occurs when a *
  377. * harvester starts driving off of a refinery. *
  378. * *
  379. * INPUT: track -- The track number to start on. *
  380. * *
  381. * coord -- The coordinate that the unit will end up at when the movement track *
  382. * is completed. *
  383. * *
  384. * OUTPUT: none *
  385. * *
  386. * WARNINGS: none *
  387. * *
  388. * HISTORY: *
  389. * 03/17/1995 JLB : Created. *
  390. *=============================================================================================*/
  391. void DriveClass::Force_Track(int track, COORDINATE coord)
  392. {
  393. assert(IsActive);
  394. TrackNumber = track;
  395. TrackIndex = 0;
  396. if (coord != 0) {
  397. Start_Driver(coord);
  398. }
  399. }
  400. /***********************************************************************************************
  401. * DriveClass::DriveClass -- Constructor for drive class object. *
  402. * *
  403. * This will initialize the drive class to its default state. It is called as a result *
  404. * of creating a unit. *
  405. * *
  406. * INPUT: classid -- The unit's ID class. It is passed on to the foot class constructor. *
  407. * *
  408. * OUTPUT: none *
  409. * *
  410. * WARNINGS: none *
  411. * *
  412. * HISTORY: *
  413. * 07/13/1994 JLB : Created. *
  414. *=============================================================================================*/
  415. DriveClass::DriveClass(RTTIType rtti, int id, HousesType house) :
  416. FootClass(rtti, id, house),
  417. IsMoebius(false),
  418. IsHarvesting(false),
  419. IsTurretLockedDown(false),
  420. IsOnShortTrack(false),
  421. SpeedAccum(0),
  422. MoebiusCountDown(0),
  423. MoebiusCell(0),
  424. TrackNumber(-1),
  425. TrackIndex(0)
  426. {
  427. }
  428. #ifdef CHEAT_KEYS
  429. /***********************************************************************************************
  430. * DriveClass::Debug_Dump -- Displays status information to monochrome screen. *
  431. * *
  432. * This debug utility function will display the status of the drive class to the mono *
  433. * screen. It is through this information that bugs can be tracked down. *
  434. * *
  435. * INPUT: none *
  436. * *
  437. * OUTPUT: none *
  438. * *
  439. * WARNINGS: none *
  440. * *
  441. * HISTORY: *
  442. * 05/31/1994 JLB : Created. *
  443. *=============================================================================================*/
  444. void DriveClass::Debug_Dump(MonoClass * mono) const
  445. {
  446. assert(IsActive);
  447. mono->Fill_Attrib(66, 14, 12, 1, IsMoebius ? MonoClass::INVERSE : MonoClass::NORMAL);
  448. FootClass::Debug_Dump(mono);
  449. }
  450. #endif
  451. /***********************************************************************************************
  452. * DriveClass::Smooth_Turn -- Handles the low level coord calc for smooth turn logic. *
  453. * *
  454. * This routine calculates the new coordinate value needed for the *
  455. * smooth turn logic. The adjustment and flag values must be *
  456. * determined prior to entering this routine. *
  457. * *
  458. * INPUT: adj -- The adjustment coordinate as lifted from the *
  459. * correct smooth turn table. *
  460. * *
  461. * dir -- Pointer to dir for possible modification *
  462. * according to the flag bits. *
  463. * *
  464. * OUTPUT: Returns with the coordinate the unit should positioned to. *
  465. * *
  466. * WARNINGS: none *
  467. * *
  468. * HISTORY: *
  469. * 03/14/1994 JLB : Created. *
  470. * 07/13/1994 JLB : Converted to member function. *
  471. *=============================================================================================*/
  472. COORDINATE DriveClass::Smooth_Turn(COORDINATE adj, DirType & dir)
  473. {
  474. assert(IsActive);
  475. DirType workdir = dir;
  476. int x,y;
  477. int temp;
  478. TrackControlType flags = TrackControl[TrackNumber].Flag;
  479. x = Coord_X(adj);
  480. y = Coord_Y(adj);
  481. if (flags & F_T) {
  482. temp = x;
  483. x = y;
  484. y = temp;
  485. workdir = (DirType)(DIR_W - workdir);
  486. }
  487. if (flags & F_X) {
  488. x = -x;
  489. workdir = (DirType)-workdir;
  490. }
  491. if (flags & F_Y) {
  492. y = -y;
  493. workdir = (DirType)(DIR_S - workdir);
  494. }
  495. dir = workdir;
  496. return(XY_Coord( (LEPTON)(Coord_X(Head_To_Coord()) + x), (LEPTON)(Coord_Y(Head_To_Coord()) + y)));
  497. }
  498. /***********************************************************************************************
  499. * DriveClass::Assign_Destination -- Set the unit's NavCom. *
  500. * *
  501. * This routine is used to set the unit's navigation computer to the *
  502. * specified target. Once the navigation computer is set, the unit *
  503. * will start planning and moving toward the destination. *
  504. * *
  505. * INPUT: target -- The destination target for the unit to head to. *
  506. * *
  507. * OUTPUT: none *
  508. * *
  509. * WARNINGS: none *
  510. * *
  511. * HISTORY: *
  512. * 09/07/1992 JLB : Created. *
  513. * 04/15/1994 JLB : Converted to member function. *
  514. *=============================================================================================*/
  515. void DriveClass::Assign_Destination(TARGET target)
  516. {
  517. assert(IsActive);
  518. /*
  519. ** Abort early if there is anything wrong with the parameters
  520. ** or the unit already is assigned the specified destination.
  521. */
  522. if (target == NavCom) return;
  523. /*
  524. ** For harvesting type vehicles, it might go into a dock and unload procedure
  525. ** when the harvester is full and an empty refinery is selected as a target.
  526. */
  527. BuildingClass * b = As_Building(target);
  528. /*
  529. ** If the player clicked on refinery but it is not busy, then assign
  530. ** it to unload at the refinery.
  531. */
  532. if (b != NULL && *b == STRUCT_REFINERY && What_Am_I() == RTTI_UNIT && ((UnitTypeClass *)Techno_Type_Class())->IsToHarvest) {
  533. if (Contact_With_Whom() != b && !b->In_Radio_Contact()) {
  534. /*
  535. ** Establish radio contact protocol. If the facility responds correctly,
  536. ** then remain in radio contact and proceed toward the desired destination.
  537. */
  538. if (Transmit_Message(RADIO_HELLO, b) == RADIO_ROGER) {
  539. if (Mission != MISSION_ENTER && Mission != MISSION_HARVEST) {
  540. Assign_Mission(MISSION_ENTER);
  541. target = TARGET_NONE;
  542. } else {
  543. // target = TARGET_NONE;
  544. }
  545. } else {
  546. // target = TARGET_NONE;
  547. }
  548. } else {
  549. // target = TARGET_NONE;
  550. }
  551. }
  552. /*
  553. ** Set the unit's navigation computer.
  554. */
  555. FootClass::Assign_Destination(target);
  556. Path[0] = FACING_NONE; // Force recalculation of path.
  557. if (!IsDriving && Mission != MISSION_UNLOAD) {
  558. Start_Of_Move();
  559. }
  560. }
  561. /***********************************************************************************************
  562. * DriveClass::While_Moving -- Processes unit movement. *
  563. * *
  564. * This routine is used to process movement for the units as they move. *
  565. * It is called many times for each cell's worth of movement. This *
  566. * routine only applies after the next cell HeadTo has been determined. *
  567. * *
  568. * INPUT: none *
  569. * *
  570. * OUTPUT: true/false; Should this routine be called again? *
  571. * *
  572. * WARNINGS: none *
  573. * *
  574. * HISTORY: *
  575. * 02/02/1992 JLB : Created. *
  576. * 04/15/1994 JLB : Converted to member function. *
  577. *=============================================================================================*/
  578. bool DriveClass::While_Moving(void)
  579. {
  580. assert(IsActive);
  581. /*
  582. ** Perform quick legality checks.
  583. */
  584. if (!IsDriving || TrackNumber == -1 || (IsRotating && !Techno_Type_Class()->IsTurretEquipped)) {
  585. SpeedAccum = 0; // Kludge? No speed should accumulate if movement is on hold.
  586. return(false);
  587. }
  588. /*
  589. ** If enough movement has accumulated so that the unit can
  590. ** visibly move on the map, then process accordingly.
  591. ** Slow the unit down if he's carrying a flag.
  592. */
  593. MPHType maxspeed = MPHType(min(Techno_Type_Class()->MaxSpeed * SpeedBias * House->GroundspeedBias, (int)MPH_LIGHT_SPEED));
  594. if (IsFormationMove) maxspeed = FormationMaxSpeed;
  595. int actual; // Working movement addition value.
  596. if (((UnitClass *)this)->Flagged != HOUSE_NONE) {
  597. actual = SpeedAccum + ((int)maxspeed/2) * fixed(Speed, 256);
  598. } else {
  599. actual = SpeedAccum + maxspeed * fixed(Speed, 256);
  600. }
  601. if (actual > PIXEL_LEPTON_W) {
  602. TurnTrackType const * track; // Track control pointer.
  603. TrackType const * ptr; // Pointer to coord offset values.
  604. int tracknum; // The track number being processed.
  605. FacingType nextface; // Next facing queued in path.
  606. bool adj; // Is a turn coming up?
  607. track = &TrackControl[TrackNumber];
  608. if (IsOnShortTrack) {
  609. tracknum = track->StartTrack;
  610. } else {
  611. tracknum = track->Track;
  612. }
  613. ptr = RawTracks[tracknum-1].Track;
  614. nextface = Path[0];
  615. /*
  616. ** Determine if there is a turn coming up. If there is
  617. ** a turn, then track jumping might occur.
  618. */
  619. adj = false;
  620. if (nextface != FACING_NONE && Dir_Facing(track->Facing) != nextface) {
  621. adj = true;
  622. }
  623. /*
  624. ** Skip ahead the number of track steps required (limited only
  625. ** by track length). Set the unit to the new position and
  626. ** flag the unit accordingly.
  627. */
  628. Mark(MARK_UP);
  629. while (actual > PIXEL_LEPTON_W) {
  630. COORDINATE offset;
  631. DirType dir;
  632. actual -= PIXEL_LEPTON_W;
  633. offset = ptr[TrackIndex].Offset;
  634. if (offset || !TrackIndex) {
  635. dir = ptr[TrackIndex].Facing;
  636. Coord = Smooth_Turn(offset, dir);
  637. PrimaryFacing.Set(dir);
  638. /*
  639. ** See if "per cell" processing is necessary.
  640. */
  641. if (TrackIndex && RawTracks[tracknum-1].Cell == TrackIndex) {
  642. Mark(MARK_DOWN);
  643. Per_Cell_Process(PCP_DURING);
  644. if (!IsActive) {
  645. return(false);
  646. }
  647. Mark(MARK_UP);
  648. }
  649. /*
  650. ** The unit could "jump tracks". Check to see if the unit should
  651. ** do so.
  652. */
  653. if (/**this != UNIT_GUNBOAT &&*/ nextface != FACING_NONE && adj && RawTracks[tracknum-1].Jump == TrackIndex && TrackIndex) {
  654. TurnTrackType const * newtrack; // Proposed jump-to track.
  655. int tnum;
  656. tnum = (int)(Dir_Facing(track->Facing) * FACING_COUNT) + (int)nextface;
  657. newtrack = &TrackControl[tnum];
  658. if (newtrack->Track && RawTracks[newtrack->Track-1].Entry) {
  659. COORDINATE c = Head_To_Coord();
  660. int oldspeed = Speed;
  661. c = Adjacent_Cell(c, nextface);
  662. switch (Can_Enter_Cell(Coord_Cell(c), nextface)) {
  663. case MOVE_OK:
  664. IsOnShortTrack = false; // Shouldn't be necessary, but...
  665. TrackNumber = tnum;
  666. track = newtrack;
  667. tracknum = track->Track;
  668. TrackIndex = RawTracks[tracknum-1].Entry-1; // Anticipate increment.
  669. ptr = RawTracks[tracknum-1].Track;
  670. adj = false;
  671. Stop_Driver();
  672. IsDriving = true;
  673. Per_Cell_Process(PCP_END);
  674. IsDriving = false;
  675. if (!IsActive) return(false);
  676. if (Start_Driver(c)) {
  677. Set_Speed(oldspeed);
  678. memcpy((char*)&Path[0], (char*)&Path[1], CONQUER_PATH_MAX-1);
  679. Path[CONQUER_PATH_MAX-1] = FACING_NONE;
  680. } else {
  681. Path[0] = FACING_NONE;
  682. TrackNumber = -1;
  683. actual = 0;
  684. }
  685. break;
  686. case MOVE_CLOAK:
  687. Map[c].Shimmer();
  688. break;
  689. case MOVE_TEMP:
  690. #ifdef TOFIX
  691. if (*this == UNIT_HARVESTER || !House->IsHuman) {
  692. #else
  693. if (!House->IsHuman) {
  694. #endif
  695. Map[c].Incoming(0, true, true);
  696. }
  697. break;
  698. }
  699. }
  700. }
  701. TrackIndex++;
  702. } else {
  703. actual = 0;
  704. Coord = Head_To_Coord();
  705. Stop_Driver();
  706. TrackNumber = -1;
  707. TrackIndex = NULL;
  708. /*
  709. ** Perform "per cell" activities.
  710. */
  711. Mark(MARK_DOWN);
  712. Per_Cell_Process(PCP_END);
  713. if (!IsActive) return(false);
  714. Mark(MARK_UP);
  715. break;
  716. }
  717. }
  718. if (IsActive) {
  719. Mark(MARK_DOWN);
  720. }
  721. }
  722. /*
  723. ** Replace any remainder back into the unit's movement
  724. ** accumulator to be processed next pass.
  725. */
  726. SpeedAccum = actual;
  727. return(true);
  728. }
  729. /***********************************************************************************************
  730. * DriveClass::Per_Cell_Process -- Handles when unit finishes movement into a cell. *
  731. * *
  732. * This routine is called when a unit has mostly or completely *
  733. * entered a cell. The unit might be in the middle of a movement track *
  734. * when this routine is called. It's primary purpose is to perform *
  735. * sighting and other "per cell" activities. *
  736. * *
  737. * INPUT: why -- Specifies the circumstances under which this routine was called. *
  738. * *
  739. * OUTPUT: none *
  740. * *
  741. * WARNINGS: none *
  742. * *
  743. * HISTORY: *
  744. * 11/03/1993 JLB : Created. *
  745. * 03/30/1994 JLB : Revamped for track system. *
  746. * 04/15/1994 JLB : Converted to member function. *
  747. * 06/18/1994 JLB : Converted to virtual function. *
  748. * 06/18/1994 JLB : Distinguishes between center and near-center conditions. *
  749. *=============================================================================================*/
  750. void DriveClass::Per_Cell_Process(PCPType why)
  751. {
  752. assert(IsActive);
  753. if (why == PCP_END) {
  754. CELL cell = Coord_Cell(Coord);
  755. /*
  756. ** Check to see if it has reached its destination. If so, then clear the NavCom
  757. ** regardless of the remaining path list.
  758. */
  759. if (As_Cell(NavCom) == cell) {
  760. IsTurretLockedDown = false;
  761. NavCom = TARGET_NONE;
  762. Path[0] = FACING_NONE;
  763. }
  764. Lay_Track();
  765. }
  766. FootClass::Per_Cell_Process(why);
  767. }
  768. /***********************************************************************************************
  769. * DriveClass::Start_Of_Move -- Tries to get a unit to advance toward cell. *
  770. * *
  771. * This will try to start a unit advancing toward the cell it is *
  772. * facing. It will check for and handle legality and reserving of the *
  773. * necessary cell. *
  774. * *
  775. * INPUT: none *
  776. * *
  777. * OUTPUT: true/false; Should this routine be called again because *
  778. * initial start operation is temporarily delayed? *
  779. * *
  780. * WARNINGS: none *
  781. * *
  782. * HISTORY: *
  783. * 02/02/1992 JLB : Created. *
  784. * 10/18/1993 JLB : This should be called repeatedly until HeadTo is not NULL. *
  785. * 03/16/1994 JLB : Revamped for track logic. *
  786. * 04/15/1994 JLB : Converted to member function. *
  787. * 06/19/1995 JLB : Fixed so that it won't fire on ground unnecessarily. *
  788. * 07/13/1995 JLB : Handles bumping into cloaked objects. *
  789. * 09/22/1995 JLB : Breaks out of hopeless hunt mode. *
  790. * 07/10/1996 JLB : Sets scan limit if necessary. *
  791. *=============================================================================================*/
  792. bool DriveClass::Start_Of_Move(void)
  793. {
  794. assert(IsActive);
  795. FacingType facing; // Direction movement will commence.
  796. DirType dir; // Desired actual facing toward destination.
  797. int facediff; // Difference between current and desired facing.
  798. int speed; // Speed of unit.
  799. CELL destcell; // Cell of destination.
  800. LandType ground; // Ground unit is entering.
  801. COORDINATE dest; // Destination coordinate.
  802. facing = Path[0];
  803. if (!Target_Legal(NavCom) && facing == FACING_NONE) {
  804. IsTurretLockedDown = false;
  805. Stop_Driver();
  806. if (Mission == MISSION_MOVE) {
  807. Enter_Idle_Mode();
  808. }
  809. return(false); // Why is it calling this routine!?!
  810. }
  811. /*
  812. ** Reduce the path length if the target is a unit and the
  813. ** range to the unit is less than the precalculated path steps.
  814. */
  815. if (facing != FACING_NONE) {
  816. int dist;
  817. if (Is_Target_Vessel(NavCom) || Is_Target_Unit(NavCom) || Is_Target_Infantry(NavCom)) {
  818. dist = Lepton_To_Cell((LEPTON)Distance(NavCom));
  819. if (dist < ARRAY_SIZE(Path)) {
  820. Path[dist] = FACING_NONE;
  821. facing = Path[0]; // Maybe needed.
  822. }
  823. }
  824. }
  825. /*
  826. ** If the path is invalid at this point, then generate one. If
  827. ** generating a new path fails, then abort NavCom.
  828. */
  829. if (facing == FACING_NONE) {
  830. /*
  831. ** If after a path search, there is still no valid path, then set the
  832. ** NavCom to null and let the script take care of assigning a new
  833. ** navigation target.
  834. */
  835. if (PathDelay != 0) {
  836. return(false);
  837. }
  838. if (!Basic_Path()) {
  839. /*
  840. ** If the unit is close enough to the target then just stop
  841. ** driving now. This prevents the fidgeting that would occur
  842. ** if they mindlessly kept trying to get to the exact location
  843. ** desired. This is quite necessary since it is typical to move
  844. ** several units with the same mouse click.
  845. */
  846. if (!Is_On_Priority_Mission() && Distance(NavCom) < Rule.CloseEnoughDistance && (Mission == MISSION_MOVE || Mission == MISSION_GUARD_AREA)) {
  847. Assign_Destination(TARGET_NONE);
  848. if (!IsActive) return(false);
  849. } else {
  850. /*
  851. ** If a basic path could not be found, but the immediate move destination is
  852. ** blocked by a friendly temporary blockage, then cause that blockage
  853. ** to scatter.
  854. */
  855. CELL cell = Adjacent_Cell(Coord_Cell(Center_Coord()), PrimaryFacing.Current());
  856. if (Map.In_Radar(cell)) {
  857. MoveType ok = Can_Enter_Cell(cell);
  858. if (ok == MOVE_TEMP) {
  859. CellClass * cellptr = &Map[cell];
  860. TechnoClass * blockage = cellptr->Cell_Techno();
  861. if (blockage && House->Is_Ally(blockage)) {
  862. /*
  863. ** If the target can be told to get out of the way, only bother
  864. ** to do so if we aren't very close to the target and this
  865. ** object can just say "good enough" and stop here.
  866. */
  867. if (Distance(NavCom) < Rule.CloseEnoughDistance && !In_Radio_Contact()) {
  868. Assign_Destination(TARGET_NONE);
  869. return(false);
  870. } else {
  871. cellptr->Incoming(0, true, false);
  872. // cellptr->Incoming(0, true, true);
  873. }
  874. }
  875. }
  876. }
  877. if (TryTryAgain > 0) {
  878. TryTryAgain--;
  879. } else {
  880. Assign_Destination(TARGET_NONE);
  881. if (!IsActive) return(false);
  882. if (IsNewNavCom) Sound_Effect(VOC_SCOLD);
  883. IsNewNavCom = false;
  884. }
  885. }
  886. /*
  887. ** Since the path was blocked, check to make sure that it was completely
  888. ** blocked. If so and it has a valid TarCom and it is out of range of the
  889. ** TarCom, then give this unit a range limit so that it might not pick
  890. ** a "can't reach" target again.
  891. */
  892. if (!Target_Legal(NavCom) && Target_Legal(TarCom) && !In_Range(TarCom)) {
  893. IsScanLimited = true;
  894. if (Team.Is_Valid()) Team->Scan_Limit();
  895. Assign_Target(TARGET_NONE);
  896. }
  897. /*
  898. ** Stop the movement, for now, and let the subsequent logic in later game
  899. ** frames resume movement as appropriate.
  900. */
  901. Stop_Driver();
  902. TrackNumber = -1;
  903. IsTurretLockedDown = false;
  904. return(false);
  905. }
  906. /*
  907. ** If a basic path could be found, but the immediate move destination is
  908. ** blocked by a friendly temporary blockage, then cause that blockage
  909. ** to scatter.
  910. */
  911. CELL cell = Adjacent_Cell(Coord_Cell(Center_Coord()), Path[0]);
  912. if (Map.In_Radar(cell)) {
  913. MoveType ok = Can_Enter_Cell(cell);
  914. if (ok == MOVE_TEMP) {
  915. CellClass * cellptr = &Map[cell];
  916. TechnoClass * blockage = cellptr->Cell_Techno();
  917. if (blockage && House->Is_Ally(blockage)) {
  918. /*
  919. ** If the target can be told to get out of the way, only bother
  920. ** to do so if we aren't very close to the target and this
  921. ** object can just say "good enough" and stop here.
  922. */
  923. if (Distance(NavCom) < Rule.CloseEnoughDistance && !In_Radio_Contact()) {
  924. Assign_Destination(TARGET_NONE);
  925. return(false);
  926. } else {
  927. cellptr->Incoming(0, true, false);
  928. // cellptr->Incoming(0, true, true);
  929. }
  930. }
  931. }
  932. }
  933. TryTryAgain = PATH_RETRY;
  934. facing = Path[0];
  935. }
  936. /*
  937. ** Determine the coordinate of the next cell to move into.
  938. */
  939. dest = Adjacent_Cell(Coord, facing);
  940. dir = Facing_Dir(facing);
  941. /*
  942. ** Set the facing correctly if it isn't already correct. This
  943. ** means starting a rotation track if necessary.
  944. */
  945. facediff = PrimaryFacing.Difference(dir);
  946. if (facediff) {
  947. /*
  948. ** Request a change of facing.
  949. */
  950. Do_Turn(dir);
  951. return(true);
  952. } else {
  953. /* NOTE: Beyond this point, actual track assignment can begin.
  954. **
  955. ** If the cell to move into is impassable (probably for some unexpected
  956. ** reason), then abort the path list and set the speed to zero. The
  957. ** next time this routine is called, a new path will be generated.
  958. */
  959. destcell = Coord_Cell(dest);
  960. Mark(MARK_UP);
  961. MoveType cando = Can_Enter_Cell(destcell, facing);
  962. Mark(MARK_DOWN);
  963. if (cando != MOVE_OK) {
  964. if (Mission == MISSION_MOVE /*KO&& House->IsHuman */&& Distance(NavCom) < Rule.CloseEnoughDistance) {
  965. Assign_Destination(TARGET_NONE);
  966. if (!IsActive) return(false);//BG
  967. }
  968. /*
  969. ** If a temporary friendly object is blocking the path, then cause it to
  970. ** get out of the way.
  971. */
  972. if (cando == MOVE_TEMP) {
  973. Map[destcell].Incoming(0, true, true);
  974. }
  975. /*
  976. ** If a cloaked object is blocking, then shimmer the cell.
  977. */
  978. if (cando == MOVE_CLOAK) {
  979. Map[destcell].Shimmer();
  980. }
  981. Stop_Driver();
  982. if (cando != MOVE_MOVING_BLOCK) {
  983. Path[0] = FACING_NONE; // Path is blocked!
  984. }
  985. /*
  986. ** If blocked by a moving block then just exit start of move and
  987. ** try again next tick.
  988. */
  989. if (cando == MOVE_DESTROYABLE) {
  990. if (Map[destcell].Cell_Object()) {
  991. if (!House->Is_Ally(Map[destcell].Cell_Object())) {
  992. Override_Mission(MISSION_ATTACK, Map[destcell].Cell_Object()->As_Target(), TARGET_NONE);
  993. }
  994. } else {
  995. if (Map[destcell].Overlay != OVERLAY_NONE && OverlayTypeClass::As_Reference(Map[destcell].Overlay).IsWall) {
  996. Override_Mission(MISSION_ATTACK, ::As_Target(destcell), TARGET_NONE);
  997. }
  998. }
  999. } else {
  1000. if (IsNewNavCom) Sound_Effect(VOC_SCOLD);
  1001. }
  1002. IsNewNavCom = false;
  1003. TrackNumber = -1;
  1004. return(true);
  1005. }
  1006. /*
  1007. ** Determine the speed that the unit can travel to the desired square.
  1008. */
  1009. ground = Map[destcell].Land_Type();
  1010. speed = Ground[ground].Cost[Techno_Type_Class()->Speed] * 256;
  1011. /* change speed if it's related to a team move */
  1012. if (IsFormationMove) speed = Ground[ground].Cost[FormationSpeed] * 256;
  1013. if (!speed) speed = 128;
  1014. #ifdef NEVER
  1015. /*
  1016. ** Set the jiggle flag if the terrain would cause the unit
  1017. ** to jiggle when travelled over.
  1018. */
  1019. BaseF &= ~BASEF_JIGGLE;
  1020. if (Ground[ground].Jiggle) {
  1021. BaseF |= BASEF_JIGGLE;
  1022. }
  1023. #endif
  1024. /*
  1025. ** A damaged unit has a reduced speed.
  1026. */
  1027. if (Health_Ratio() <= Rule.ConditionYellow /*(Techno_Type_Class()->MaxStrength>>1) > Strength*/) {
  1028. speed -= (speed/4); // Three quarters speed.
  1029. }
  1030. if ((speed != Speed)/* || !SpeedAdd*/) {
  1031. Set_Speed(speed); // Full speed.
  1032. }
  1033. /*
  1034. ** Reserve the destination cell so that it won't become
  1035. ** occupied AS this unit is moving into it.
  1036. */
  1037. if (cando != MOVE_OK) {
  1038. Path[0] = FACING_NONE; // Path is blocked!
  1039. TrackNumber = -1;
  1040. dest = NULL;
  1041. } else {
  1042. Overrun_Square(Coord_Cell(dest), true);
  1043. /*
  1044. ** Determine which track to use (based on recorded path).
  1045. */
  1046. FacingType nextface = Path[1];
  1047. if (nextface == FACING_NONE) nextface = facing;
  1048. IsOnShortTrack = false;
  1049. TrackNumber = facing * FACING_COUNT + (int)nextface;
  1050. if (TrackControl[TrackNumber].Track == 0) {
  1051. Path[0] = FACING_NONE;
  1052. TrackNumber = -1;
  1053. return(true);
  1054. } else {
  1055. if (TrackControl[TrackNumber].Flag & F_D) {
  1056. /*
  1057. ** If the middle cell of a two cell track contains a crate,
  1058. ** the check for goodies before movement starts.
  1059. */
  1060. if (!Map[destcell].Goodie_Check(this)) {
  1061. cando = MOVE_NO;
  1062. if (!IsActive) return(false);
  1063. } else {
  1064. if (!IsActive) return(false);
  1065. dest = Adjacent_Cell(dest, nextface);
  1066. destcell = Coord_Cell(dest);
  1067. cando = Can_Enter_Cell(destcell);
  1068. }
  1069. if (!IsActive) return(false);
  1070. if (cando != MOVE_OK) {
  1071. /*
  1072. ** If a temporary friendly object is blocking the path, then cause it to
  1073. ** get out of the way.
  1074. */
  1075. if (cando == MOVE_TEMP) {
  1076. Map[destcell].Incoming(0, true, true);
  1077. }
  1078. /*
  1079. ** If a cloaked object is blocking, then shimmer the cell.
  1080. */
  1081. if (cando == MOVE_CLOAK) {
  1082. Map[destcell].Shimmer();
  1083. }
  1084. Path[0] = FACING_NONE; // Path is blocked!
  1085. TrackNumber = -1;
  1086. dest = NULL;
  1087. if (cando == MOVE_DESTROYABLE) {
  1088. if (Map[destcell].Cell_Object()) {
  1089. if (!House->Is_Ally(Map[destcell].Cell_Object())) {
  1090. Override_Mission(MISSION_ATTACK, Map[destcell].Cell_Object()->As_Target(), TARGET_NONE);
  1091. }
  1092. } else {
  1093. if (Map[destcell].Overlay != OVERLAY_NONE && OverlayTypeClass::As_Reference(Map[destcell].Overlay).IsWall) {
  1094. Override_Mission(MISSION_ATTACK, ::As_Target(destcell), TARGET_NONE);
  1095. }
  1096. }
  1097. IsNewNavCom = false;
  1098. TrackIndex = 0;
  1099. return(true);
  1100. }
  1101. } else {
  1102. memcpy((char*)&Path[0], (char*)&Path[2], CONQUER_PATH_MAX-2);
  1103. Path[CONQUER_PATH_MAX-2] = FACING_NONE;
  1104. IsPlanningToLook = true;
  1105. }
  1106. } else {
  1107. memcpy((char*)&Path[0], (char*)&Path[1], CONQUER_PATH_MAX-1);
  1108. }
  1109. Path[CONQUER_PATH_MAX-1] = FACING_NONE;
  1110. }
  1111. }
  1112. IsNewNavCom = false;
  1113. TrackIndex = 0;
  1114. if (!Start_Driver(dest)) {
  1115. TrackNumber = -1;
  1116. Path[0] = FACING_NONE;
  1117. Set_Speed(0);
  1118. }
  1119. }
  1120. return(false);
  1121. }
  1122. /***********************************************************************************************
  1123. * DriveClass::AI -- Processes unit movement and rotation. *
  1124. * *
  1125. * This routine is used to process unit movement and rotation. It *
  1126. * functions autonomously from the script system. Thus, once a unit *
  1127. * is give rotation command or movement path, it will follow this *
  1128. * until specifically instructed to stop. The advantage of this *
  1129. * method is that it allows smooth movement of units, faster game *
  1130. * execution, and reduced script complexity (since actual movement *
  1131. * dynamics need not be controlled directly by the scripts). *
  1132. * *
  1133. * INPUT: none *
  1134. * *
  1135. * OUTPUT: none *
  1136. * *
  1137. * WARNINGS: This routine relies on the process control bits for the *
  1138. * specified unit (for speed reasons). Thus, only setting *
  1139. * movement, rotation, or path list will the unit perform *
  1140. * any physics. *
  1141. * *
  1142. * HISTORY: *
  1143. * 09/26/1993 JLB : Created. *
  1144. * 04/15/1994 JLB : Converted to member function. *
  1145. *=============================================================================================*/
  1146. void DriveClass::AI(void)
  1147. {
  1148. assert(IsActive);
  1149. FootClass::AI();
  1150. if (!IsActive || Height > 0) return;
  1151. /*
  1152. ** Is this a unit that's been teleported using the chronosphere, and if so,
  1153. ** has his timer expired such that he needs to teleport back?
  1154. */
  1155. if (IsMoebius) {
  1156. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  1157. if (What_Am_I() != RTTI_UNIT || ((UnitClass *)this)->Class->Type != UNIT_CHRONOTANK) {
  1158. #endif
  1159. if (MoebiusCountDown == 0) {
  1160. IsMoebius = false;
  1161. Teleport_To(MoebiusCell);
  1162. MoebiusCell = 0;
  1163. }
  1164. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  1165. }
  1166. #endif
  1167. }
  1168. /*
  1169. ** If the unit is following a track, then continue
  1170. ** to do so -- mindlessly.
  1171. */
  1172. if (TrackNumber != -1) {
  1173. /*
  1174. ** Perform the movement accumulation.
  1175. */
  1176. While_Moving();
  1177. if (!IsActive) return;
  1178. if (TrackNumber == -1 && (Target_Legal(NavCom) || Path[0] != FACING_NONE) && (What_Am_I() != RTTI_UNIT || !((UnitClass*)this)->IsDumping)) {
  1179. Start_Of_Move();
  1180. if (!IsActive) return;
  1181. While_Moving();
  1182. if (!IsActive) return;
  1183. }
  1184. } else {
  1185. /*
  1186. ** For tracked units that are rotating in place, perform the rotation now.
  1187. */
  1188. #ifdef TOFIX
  1189. if ((Class->Speed == SPEED_FLOAT || Class->Speed == SPEED_HOVER || Class->Speed == SPEED_TRACK || (Class->Speed == SPEED_WHEEL && !Special.IsThreePoint)) && PrimaryFacing.Is_Rotating()) {
  1190. if (PrimaryFacing.Rotation_Adjust(Class->ROT)) {
  1191. Mark(MARK_CHANGE);
  1192. }
  1193. #else
  1194. if (PrimaryFacing.Is_Rotating()) {
  1195. Mark(MARK_CHANGE_REDRAW);
  1196. if (PrimaryFacing.Rotation_Adjust(Techno_Type_Class()->ROT * House->GroundspeedBias)) {
  1197. Mark(MARK_CHANGE_REDRAW);
  1198. }
  1199. #endif
  1200. if (!IsRotating) {
  1201. Per_Cell_Process(PCP_ROTATION);
  1202. if (!IsActive) return;
  1203. }
  1204. } else {
  1205. /*
  1206. ** The unit has no track to follow, but if there
  1207. ** is a navigation target or a remaining path,
  1208. ** then start on a new track.
  1209. */
  1210. if ((Mission != MISSION_GUARD || Target_Legal(NavCom)) && Mission != MISSION_UNLOAD) {
  1211. if (Target_Legal(NavCom) || Path[0] != FACING_NONE) {
  1212. /*
  1213. ** Double check to make sure that the movement destination is
  1214. ** in a zone that this unit can travel to. If not, then abort
  1215. ** the navigation target.
  1216. */
  1217. if (IsLocked && Mission != MISSION_ENTER && Target_Legal(NavCom) && !Is_In_Same_Zone(As_Cell(NavCom))) {
  1218. Stop_Driver();
  1219. Assign_Destination(TARGET_NONE);
  1220. } else {
  1221. Start_Of_Move();
  1222. if (!IsActive) return;
  1223. While_Moving();
  1224. if (!IsActive) return;
  1225. }
  1226. } else {
  1227. Stop_Driver();
  1228. }
  1229. }
  1230. }
  1231. }
  1232. }
  1233. /***********************************************************************************************
  1234. * DriveClass::Fixup_Path -- Adds smooth start path to normal movement path. *
  1235. * *
  1236. * This routine modifies the path of the specified unit so that it *
  1237. * will not start out with a rotation. This is necessary for those *
  1238. * vehicles that have difficulty with rotating in place. Typically, *
  1239. * this includes wheeled vehicles. *
  1240. * *
  1241. * INPUT: unit -- Pointer to the unit to adjust. *
  1242. * *
  1243. * path -- Pointer to path structure. *
  1244. * *
  1245. * OUTPUT: none *
  1246. * *
  1247. * WARNINGS: Only units that require a fixup get modified. The *
  1248. * modification only occurs, if there is a legal path to *
  1249. * do so. *
  1250. * *
  1251. * HISTORY: *
  1252. * 04/03/1994 JLB : Created. *
  1253. * 04/06/1994 JLB : Uses path structure. *
  1254. * 04/10/1994 JLB : Diagonal smooth turn added. *
  1255. * 04/15/1994 JLB : Converted to member function. *
  1256. *=============================================================================================*/
  1257. void DriveClass::Fixup_Path(PathType * path)
  1258. {
  1259. assert(IsActive);
  1260. FacingType stage[6]={FACING_N,FACING_N,FACING_N,FACING_N,FACING_N,FACING_N}; // Prefix path elements.
  1261. int facediff; // The facing difference value (0..4 | 0..-4).
  1262. static FacingType _path[4][6] = {
  1263. {(FacingType)2,(FacingType)0,(FacingType)2,(FacingType)0,(FacingType)0,(FacingType)0},
  1264. {(FacingType)3,(FacingType)0,(FacingType)2,(FacingType)2,(FacingType)0,(FacingType)0},
  1265. {(FacingType)4,(FacingType)0,(FacingType)2,(FacingType)2,(FacingType)0,(FacingType)0},
  1266. {(FacingType)4,(FacingType)0,(FacingType)2,(FacingType)2,(FacingType)1,(FacingType)0}
  1267. };
  1268. static FacingType _dpath[4][6] = {
  1269. {(FacingType)0,(FacingType)0,(FacingType)0,(FacingType)0,(FacingType)0,(FacingType)0},
  1270. {(FacingType)3,(FacingType)0,(FacingType)2,(FacingType)2,(FacingType)0,(FacingType)0},
  1271. {(FacingType)4,(FacingType)0,(FacingType)2,(FacingType)2,(FacingType)1,(FacingType)0},
  1272. {(FacingType)5,(FacingType)0,(FacingType)2,(FacingType)2,(FacingType)1,(FacingType)0}
  1273. };
  1274. int index;
  1275. int counter; // Path addition
  1276. FacingType * ptr; // Path list pointer.
  1277. FacingType * ptr2; // Copy of new path list pointer.
  1278. FacingType nextpath; // Next path value.
  1279. CELL cell; // Working cell value.
  1280. bool ok;
  1281. /*
  1282. ** Verify that the unit is valid and there is a path problem to resolve.
  1283. */
  1284. if (!path || path->Command[0] == FACING_NONE) {
  1285. return;
  1286. }
  1287. /*
  1288. ** Only wheeled vehicles need a path fixup -- to avoid 3 point turns.
  1289. */
  1290. #ifdef TOFIX
  1291. if (!Special.IsThreePoint || Class->Speed != SPEED_WHEEL) {
  1292. #else
  1293. if (What_Am_I() == RTTI_UNIT || What_Am_I() == RTTI_VESSEL) {
  1294. // if (What_Am_I() == RTTI_UNIT) {
  1295. #endif
  1296. return;
  1297. }
  1298. /*
  1299. ** If the original path starts in the same direction as the unit, then
  1300. ** there is no problem to resolve -- abort.
  1301. */
  1302. facediff = PrimaryFacing.Difference((DirType)(path->Command[0]<<5)) >> 5;
  1303. if (!facediff) return;
  1304. if (Dir_Facing(PrimaryFacing) & FACING_NE) {
  1305. ptr = &_dpath[(FacingType)ABS((int)facediff)-FACING_NE][1]; // Pointer to path adjust list.
  1306. counter = (int)_dpath[(FacingType)ABS((int)facediff)-FACING_NE][0]; // Number of path adjusts.
  1307. } else {
  1308. ptr = &_path[(FacingType)ABS((int)facediff)-FACING_NE][1]; // Pointer to path adjust list.
  1309. counter = (int)_path[(FacingType)ABS((int)facediff)-FACING_NE][0]; // Number of path adjusts.
  1310. }
  1311. ptr2 = ptr;
  1312. ok = true; // Presume adjustment is all ok.
  1313. cell = Coord_Cell(Coord); // Starting cell.
  1314. nextpath = Dir_Facing(PrimaryFacing); // Starting path.
  1315. for (index = 0; index < counter; index++) {
  1316. /*
  1317. ** Determine next path element and add it to the
  1318. ** working path list.
  1319. */
  1320. if (facediff > 0) {
  1321. nextpath = nextpath + *ptr++;
  1322. } else {
  1323. nextpath = nextpath - *ptr++;
  1324. }
  1325. stage[index] = nextpath;
  1326. cell = Adjacent_Cell(cell, nextpath);
  1327. //cell = Coord_Cell(Adjacent_Cell(Cell_Coord(cell), nextpath));
  1328. /*
  1329. ** If it can't enter this cell, then abort the path
  1330. ** building operation without adjusting the unit's
  1331. ** path.
  1332. */
  1333. if (Can_Enter_Cell(cell, nextpath) != MOVE_OK) {
  1334. ok = false;
  1335. break;
  1336. }
  1337. }
  1338. /*
  1339. ** If veering to the left was not successful, then try veering
  1340. ** to the right. This only makes sense if the vehicle is trying
  1341. ** to turn 180 degrees.
  1342. */
  1343. if (!ok && ABS(facediff) == 4) {
  1344. ptr = ptr2; // Pointer to path adjust list.
  1345. facediff = -facediff;
  1346. ok = true; // Presume adjustment is all ok.
  1347. cell = Coord_Cell(Coord); // Starting cell.
  1348. nextpath = Dir_Facing(PrimaryFacing); // Starting path.
  1349. for (index = 0; index < counter; index++) {
  1350. /*
  1351. ** Determine next path element and add it to the
  1352. ** working path list.
  1353. */
  1354. if (facediff > 0) {
  1355. nextpath = nextpath + *ptr++;
  1356. } else {
  1357. nextpath = nextpath - *ptr++;
  1358. }
  1359. stage[index] = nextpath;
  1360. cell = Coord_Cell(Adjacent_Cell(Cell_Coord(cell), nextpath));
  1361. /*
  1362. ** If it can't enter this cell, then abort the path
  1363. ** building operation without adjusting the unit's
  1364. ** path.
  1365. */
  1366. if (Can_Enter_Cell(cell, nextpath) != MOVE_OK) {
  1367. ok = false;
  1368. break;
  1369. }
  1370. }
  1371. }
  1372. /*
  1373. ** If a legal path addition was created, then install it in place
  1374. ** of the first path value. The initial path entry is to be replaced
  1375. ** with a sequence of path entries that create smooth turning.
  1376. */
  1377. if (ok) {
  1378. if (path->Length <= 1) {
  1379. memmove((char *)&stage[0], (char*)path->Command, max(counter, 1));
  1380. path->Length = counter;
  1381. } else {
  1382. /*
  1383. ** Optimize the transition path step from the smooth turn
  1384. ** first part as it joins with the rest of the normal
  1385. ** path. The normal prefix path steps are NOT to be optimized.
  1386. */
  1387. if (counter) {
  1388. counter--;
  1389. path->Command[0] = stage[counter];
  1390. Optimize_Moves(path, MOVE_OK);
  1391. }
  1392. /*
  1393. ** If there is more than one prefix path element, then
  1394. ** insert the rest now.
  1395. */
  1396. if (counter) {
  1397. memmove((char*)&path->Command[0], (char*)&path->Command[counter], 40-counter);
  1398. memmove((char*)&stage[0], (char*)&path->Command[0], counter);
  1399. path->Length += counter;
  1400. }
  1401. }
  1402. path->Command[path->Length] = FACING_NONE;
  1403. }
  1404. }
  1405. /***********************************************************************************************
  1406. * DriveClass::Lay_Track -- Handles track laying logic for the unit. *
  1407. * *
  1408. * This routine handles the track laying for the unit. This entails examining the unit's *
  1409. * current location as well as the direction and whether this unit is allowed to lay *
  1410. * tracks in the first place. *
  1411. * *
  1412. * INPUT: none *
  1413. * *
  1414. * OUTPUT: none *
  1415. * *
  1416. * WARNINGS: none *
  1417. * *
  1418. * HISTORY: *
  1419. * 05/28/1994 JLB : Created. *
  1420. *=============================================================================================*/
  1421. void DriveClass::Lay_Track(void)
  1422. {
  1423. assert(IsActive);
  1424. #ifdef NEVER
  1425. static IconCommandType * _trackdirs[8] = {
  1426. TrackN_S,
  1427. TrackNE_SW,
  1428. TrackE_W,
  1429. TrackNW_SE,
  1430. TrackN_S,
  1431. TrackNE_SW,
  1432. TrackE_W,
  1433. TrackNW_SE
  1434. };
  1435. if (!(ClassF & CLASSF_TRACKS)) return;
  1436. Icon_Install(Coord_Cell(Coord), _trackdirs[Facing_To_8(BodyFacing)]);
  1437. #endif
  1438. }
  1439. /***********************************************************************************************
  1440. * DriveClass::Mark_Track -- Marks the midpoint of the track as occupied. *
  1441. * *
  1442. * This routine will ensure that the midpoint (if any) of the track that the unit is *
  1443. * following, will be marked according to the mark type specified. *
  1444. * *
  1445. * INPUT: headto -- The head to coordinate. *
  1446. * *
  1447. * type -- The type of marking to perform. *
  1448. * *
  1449. * OUTPUT: none *
  1450. * *
  1451. * WARNINGS: none *
  1452. * *
  1453. * HISTORY: *
  1454. * 07/30/1995 JLB : Created. *
  1455. *=============================================================================================*/
  1456. void DriveClass::Mark_Track(COORDINATE headto, MarkType type)
  1457. {
  1458. assert(IsActive);
  1459. int value;
  1460. if (type == MARK_UP) {
  1461. value = false;
  1462. } else {
  1463. value = true;
  1464. }
  1465. if (headto) {
  1466. if (!IsOnShortTrack && TrackNumber != -1) {
  1467. /*
  1468. ** If we have not passed the per cell process point we need
  1469. ** to deal with it.
  1470. */
  1471. int tracknum = TrackControl[TrackNumber].Track;
  1472. if (tracknum) {
  1473. TrackType const * ptr = RawTracks[tracknum - 1].Track;
  1474. int cellidx = RawTracks[tracknum - 1].Cell;
  1475. if (cellidx > -1) {
  1476. DirType dir = ptr[cellidx].Facing;
  1477. if (TrackIndex < cellidx && cellidx != -1) {
  1478. COORDINATE offset = Smooth_Turn(ptr[cellidx].Offset, dir);
  1479. Map[offset].Flag.Occupy.Vehicle = value;
  1480. }
  1481. }
  1482. }
  1483. }
  1484. Map[headto].Flag.Occupy.Vehicle = value;
  1485. }
  1486. }
  1487. /***********************************************************************************************
  1488. * DriveClass::Ok_To_Move -- Checks to see if this object can begin moving. *
  1489. * *
  1490. * This routine is used to verify that this object is allowed to move. Some objects can *
  1491. * be temporarily occupied and thus cannot move until the situation permits. *
  1492. * *
  1493. * INPUT: direction -- The direction that movement would be desired. *
  1494. * *
  1495. * OUTPUT: Can the unit move in the direction specified? *
  1496. * *
  1497. * WARNINGS: none *
  1498. * *
  1499. * HISTORY: *
  1500. * 07/29/1995 JLB : Created. *
  1501. *=============================================================================================*/
  1502. bool DriveClass::Ok_To_Move(DirType ) const
  1503. {
  1504. assert(IsActive);
  1505. return true;
  1506. }
  1507. /***************************************************************************
  1508. ** Smooth turn track tables. These are coordinate offsets from the center
  1509. ** of the destination cell. These are the raw tracks that are modified
  1510. ** by negating the X and Y portions as necessary. Also for reverse travelling
  1511. ** direction, the track list can be processed backward.
  1512. **
  1513. ** Track 1 = N
  1514. ** Track 2 = NE
  1515. ** Track 3 = N->NE 45 deg (double path consumption)
  1516. ** Track 4 = N->E 90 deg (double path consumption)
  1517. ** Track 5 = NE->SE 90 deg (double path consumption)
  1518. ** Track 6 = NE->N 45 deg (double path consumption)
  1519. ** Track 7 = N->NE (facing change only)
  1520. ** Track 8 = NE->E (facing change only)
  1521. ** Track 9 = N->E (facing change only)
  1522. ** Track 10= NE->SE (facing change only)
  1523. ** Track 11= back up into refinery
  1524. ** Track 12= drive out of refinery
  1525. */
  1526. #pragma warn -ias
  1527. DriveClass::TrackType const DriveClass::Track1[24] = {
  1528. {0x00F50000L,(DirType)0},
  1529. {0x00EA0000L,(DirType)0},
  1530. {0x00DF0000L,(DirType)0},
  1531. {0x00D40000L,(DirType)0},
  1532. {0x00C90000L,(DirType)0},
  1533. {0x00BE0000L,(DirType)0},
  1534. {0x00B30000L,(DirType)0},
  1535. {0x00A80000L,(DirType)0},
  1536. {0x009D0000L,(DirType)0},
  1537. {0x00920000L,(DirType)0},
  1538. {0x00870000L,(DirType)0},
  1539. {0x007C0000L,(DirType)0}, // Track jump check here.
  1540. {0x00710000L,(DirType)0},
  1541. {0x00660000L,(DirType)0},
  1542. {0x005B0000L,(DirType)0},
  1543. {0x00500000L,(DirType)0},
  1544. {0x00450000L,(DirType)0},
  1545. {0x003A0000L,(DirType)0},
  1546. {0x002F0000L,(DirType)0},
  1547. {0x00240000L,(DirType)0},
  1548. {0x00190000L,(DirType)0},
  1549. {0x000E0000L,(DirType)0},
  1550. {0x00030000L,(DirType)0},
  1551. {0x00000000L,(DirType)0}
  1552. };
  1553. DriveClass::TrackType const DriveClass::Track2[] = {
  1554. {0x00F8FF08L,(DirType)32},
  1555. {0x00F0FF10L,(DirType)32},
  1556. {0x00E8FF18L,(DirType)32},
  1557. {0x00E0FF20L,(DirType)32},
  1558. {0x00D8FF28L,(DirType)32},
  1559. {0x00D0FF30L,(DirType)32},
  1560. {0x00C8FF38L,(DirType)32},
  1561. {0x00C0FF40L,(DirType)32},
  1562. {0x00B8FF48L,(DirType)32},
  1563. {0x00B0FF50L,(DirType)32},
  1564. {0x00A8FF58L,(DirType)32},
  1565. {0x00A0FF60L,(DirType)32},
  1566. {0x0098FF68L,(DirType)32},
  1567. {0x0090FF70L,(DirType)32},
  1568. {0x0088FF78L,(DirType)32},
  1569. {0x0080FF80L,(DirType)32}, // Track jump check here.
  1570. {0x0078FF88L,(DirType)32},
  1571. {0x0070FF90L,(DirType)32},
  1572. {0x0068FF98L,(DirType)32},
  1573. {0x0060FFA0L,(DirType)32},
  1574. {0x0058FFA8L,(DirType)32},
  1575. {0x0050FFB0L,(DirType)32},
  1576. {0x0048FFB8L,(DirType)32},
  1577. {0x0040FFC0L,(DirType)32},
  1578. {0x0038FFC8L,(DirType)32},
  1579. {0x0030FFD0L,(DirType)32},
  1580. {0x0028FFD8L,(DirType)32},
  1581. {0x0020FFE0L,(DirType)32},
  1582. {0x0018FFE8L,(DirType)32},
  1583. {0x0010FFF0L,(DirType)32},
  1584. {0x0008FFF8L,(DirType)32},
  1585. {0x00000000L,(DirType)32}
  1586. };
  1587. DriveClass::TrackType const DriveClass::Track3[] = {
  1588. {0x01F5FF00L,(DirType)0},
  1589. {0x01EAFF00L,(DirType)0},
  1590. {0x01DFFF00L,(DirType)0},
  1591. {0x01D4FF00L,(DirType)0},
  1592. {0x01C9FF00L,(DirType)0},
  1593. {0x01BEFF00L,(DirType)0},
  1594. {0x01B3FF00L,(DirType)0},
  1595. {0x01A8FF00L,(DirType)0},
  1596. {0x019DFF00L,(DirType)0},
  1597. {0x0192FF00L,(DirType)0},
  1598. {0x0187FF00L,(DirType)0},
  1599. {0x0180FF00L,(DirType)0},
  1600. {0x0175FF00L,(DirType)0}, // Jump entry point here.
  1601. {0x016BFF00L,(DirType)0},
  1602. {0x0160FF02L,(DirType)1},
  1603. {0x0155FF04L,(DirType)3},
  1604. {0x014CFF06L,(DirType)4},
  1605. {0x0141FF08L,(DirType)5},
  1606. {0x0137FF0BL,(DirType)7},
  1607. {0x012EFF0FL,(DirType)8},
  1608. {0x0124FF13L,(DirType)9},
  1609. {0x011AFF17L,(DirType)11},
  1610. {0x0110FF1BL,(DirType)12},
  1611. {0x0107FF1FL,(DirType)13}, // Center cell processing here.
  1612. {0x00FCFF24L,(DirType)15},
  1613. {0x00F3FF28L,(DirType)16},
  1614. {0x00ECFF2CL,(DirType)17},
  1615. {0x00E0FF32L,(DirType)19},
  1616. {0x00D7FF36L,(DirType)20},
  1617. {0x00CFFF3DL,(DirType)21},
  1618. {0x00C6FF42L,(DirType)23},
  1619. {0x00BAFF49L,(DirType)24},
  1620. {0x00B0FF4DL,(DirType)25},
  1621. {0x00A8FF58L,(DirType)27},
  1622. {0x00A0FF60L,(DirType)28},
  1623. {0x0098FF68L,(DirType)29},
  1624. {0x0090FF70L,(DirType)31},
  1625. {0x0088FF78L,(DirType)32},
  1626. {0x0080FF80L,(DirType)32}, // Track jump check here.
  1627. {0x0078FF88L,(DirType)32},
  1628. {0x0070FF90L,(DirType)32},
  1629. {0x0068FF98L,(DirType)32},
  1630. {0x0060FFA0L,(DirType)32},
  1631. {0x0058FFA8L,(DirType)32},
  1632. {0x0050FFB0L,(DirType)32},
  1633. {0x0048FFB8L,(DirType)32},
  1634. {0x0040FFC0L,(DirType)32},
  1635. {0x0038FFC8L,(DirType)32},
  1636. {0x0030FFD0L,(DirType)32},
  1637. {0x0028FFD8L,(DirType)32},
  1638. {0x0020FFE0L,(DirType)32},
  1639. {0x0018FFE8L,(DirType)32},
  1640. {0x0010FFF0L,(DirType)32},
  1641. {0x0008FFF8L,(DirType)32},
  1642. {0x00000000L,(DirType)32}
  1643. };
  1644. DriveClass::TrackType const DriveClass::Track4[] = {
  1645. {0x00F5FF00L,(DirType)0},
  1646. {0x00EBFF00L,(DirType)0},
  1647. {0x00E0FF00L,(DirType)0},
  1648. {0x00D5FF00L,(DirType)0},
  1649. {0x00CBFF01L,(DirType)0},
  1650. {0x00C0FF03L,(DirType)0},
  1651. {0x00B5FF05L,(DirType)1},
  1652. {0x00ABFF07L,(DirType)1},
  1653. {0x00A0FF0AL,(DirType)2},
  1654. {0x0095FF0DL,(DirType)3},
  1655. {0x008BFF10L,(DirType)4},
  1656. {0x0080FF14L,(DirType)5}, // Track entry here.
  1657. {0x0075FF18L,(DirType)8},
  1658. {0x006DFF1CL,(DirType)12},
  1659. {0x0063FF22L,(DirType)16},
  1660. {0x005AFF25L,(DirType)20},
  1661. {0x0052FF2BL,(DirType)23},
  1662. {0x0048FF32L,(DirType)27},
  1663. {0x0040FF37L,(DirType)32},
  1664. {0x0038FF3DL,(DirType)36},
  1665. {0x0030FF46L,(DirType)39},
  1666. {0x002BFF4FL,(DirType)43},
  1667. {0x0024FF58L,(DirType)47},
  1668. {0x0020FF60L,(DirType)51},
  1669. {0x001BFF6DL,(DirType)54},
  1670. {0x0017FF79L,(DirType)57},
  1671. {0x0014FF82L,(DirType)60}, // Track jump here.
  1672. {0x0011FF8FL,(DirType)62},
  1673. {0x000DFF98L,(DirType)63},
  1674. {0x0009FFA2L,(DirType)64},
  1675. {0x0006FFACL,(DirType)64},
  1676. {0x0004FFB5L,(DirType)66},
  1677. {0x0003FFC0L,(DirType)64},
  1678. {0x0002FFCBL,(DirType)64},
  1679. {0x0001FFD5L,(DirType)64},
  1680. {0x0000FFE0L,(DirType)64},
  1681. {0x0000FFEBL,(DirType)64},
  1682. {0x0000FFF5L,(DirType)64},
  1683. {0x00000000L,(DirType)64}
  1684. };
  1685. DriveClass::TrackType const DriveClass::Track5[] = {
  1686. {0xFFF8FE08L,(DirType)32},
  1687. {0xFFF0FE10L,(DirType)32},
  1688. {0xFFE8FE18L,(DirType)32},
  1689. {0xFFE0FE20L,(DirType)32},
  1690. {0xFFD8FE28L,(DirType)32},
  1691. {0xFFD0FE30L,(DirType)32},
  1692. {0xFFC8FE38L,(DirType)32},
  1693. {0xFFC0FE40L,(DirType)32},
  1694. {0xFFB8FE48L,(DirType)32},
  1695. {0xFFB0FE50L,(DirType)32},
  1696. {0xFFA8FE58L,(DirType)32},
  1697. {0xFFA0FE60L,(DirType)32},
  1698. {0xFF98FE68L,(DirType)32},
  1699. {0xFF90FE70L,(DirType)32},
  1700. {0xFF88FE78L,(DirType)32},
  1701. {0xFF80FE80L,(DirType)32}, // Track entry here.
  1702. {0xFF78FE88L,(DirType)32},
  1703. {0xFF71FE90L,(DirType)32},
  1704. {0xFF6AFE97L,(DirType)32},
  1705. {0xFF62FE9FL,(DirType)32},
  1706. {0xFF5AFEA8L,(DirType)32},
  1707. {0xFF53FEB0L,(DirType)35},
  1708. {0xFF4BFEB7L,(DirType)38},
  1709. {0xFF44FEBEL,(DirType)41},
  1710. {0xFF3EFEC4L,(DirType)44},
  1711. {0xFF39FECEL,(DirType)47},
  1712. {0xFF34FED8L,(DirType)50},
  1713. {0xFF30FEE0L,(DirType)53},
  1714. {0xFF2DFEEBL,(DirType)56},
  1715. {0xFF2CFEF5L,(DirType)59},
  1716. {0xFF2BFF00L,(DirType)62},
  1717. {0xFF2CFF0BL,(DirType)66},
  1718. {0xFF2DFF15L,(DirType)69},
  1719. {0xFF30FF1FL,(DirType)72},
  1720. {0xFF34FF28L,(DirType)75},
  1721. {0xFF39FF30L,(DirType)78},
  1722. {0xFF3EFF3AL,(DirType)81},
  1723. {0xFF44FF44L,(DirType)84},
  1724. {0xFF4BFF4BL,(DirType)87},
  1725. {0xFF53FF50L,(DirType)90},
  1726. {0xFF5AFF58L,(DirType)93},
  1727. {0xFF62FF60L,(DirType)96},
  1728. {0xFF6AFF68L,(DirType)96},
  1729. {0xFF71FF70L,(DirType)96},
  1730. {0xFF78FF78L,(DirType)96},
  1731. {0xFF80FF80L,(DirType)96}, // Track jump check here.
  1732. {0xFF88FF88L,(DirType)96},
  1733. {0xFF90FF90L,(DirType)96},
  1734. {0xFF98FF98L,(DirType)96},
  1735. {0xFFA0FFA0L,(DirType)96},
  1736. {0xFFA8FFA8L,(DirType)96},
  1737. {0xFFB0FFB0L,(DirType)96},
  1738. {0xFFB8FFB8L,(DirType)96},
  1739. {0xFFC0FFC0L,(DirType)96},
  1740. {0xFFC8FFC8L,(DirType)96},
  1741. {0xFFD0FFD0L,(DirType)96},
  1742. {0xFFD8FFD8L,(DirType)96},
  1743. {0xFFE0FFE0L,(DirType)96},
  1744. {0xFFE8FFE8L,(DirType)96},
  1745. {0xFFF0FFF0L,(DirType)96},
  1746. {0xFFF8FFF8L,(DirType)96},
  1747. {0x00000000L,(DirType)96}
  1748. };
  1749. DriveClass::TrackType const DriveClass::Track6[] = {
  1750. {0x0100FE00L,(DirType)32},
  1751. {0x00F8FE08L,(DirType)32},
  1752. {0x00F0FE10L,(DirType)32},
  1753. {0x00E8FE18L,(DirType)32},
  1754. {0x00E0FE20L,(DirType)32},
  1755. {0x00D8FE28L,(DirType)32},
  1756. {0x00D0FE30L,(DirType)32},
  1757. {0x00C8FE38L,(DirType)32},
  1758. {0x00C0FE40L,(DirType)32},
  1759. {0x00B8FE48L,(DirType)32},
  1760. {0x00B0FE50L,(DirType)32},
  1761. {0x00A8FE58L,(DirType)32},
  1762. {0x00A0FE60L,(DirType)32},
  1763. {0x0098FE68L,(DirType)32},
  1764. {0x0090FE70L,(DirType)32},
  1765. {0x0088FE78L,(DirType)32},
  1766. {0x0080FE80L,(DirType)32}, // Jump entry point here.
  1767. {0x0078FE88L,(DirType)32},
  1768. {0x0070FE90L,(DirType)32},
  1769. {0x0068FE98L,(DirType)32},
  1770. {0x0060FEA0L,(DirType)32},
  1771. {0x0058FEA8L,(DirType)32},
  1772. {0x0055FEAEL,(DirType)32},
  1773. {0x004EFEB8L,(DirType)35},
  1774. {0x0048FEC0L,(DirType)37},
  1775. {0x0042FEC9L,(DirType)40},
  1776. {0x003BFED2L,(DirType)43},
  1777. {0x0037FEDAL,(DirType)45},
  1778. {0x0032FEE3L,(DirType)48},
  1779. {0x002BFEEBL,(DirType)51},
  1780. {0x0026FEF5L,(DirType)53},
  1781. {0x0022FEFEL,(DirType)56},
  1782. {0x001CFF08L,(DirType)59},
  1783. {0x0019FF12L,(DirType)61},
  1784. {0x0015FF1BL,(DirType)64},
  1785. {0x0011FF26L,(DirType)64},
  1786. {0x000EFF30L,(DirType)64},
  1787. {0x000BFF39L,(DirType)64},
  1788. {0x0009FF43L,(DirType)64},
  1789. {0x0007FF4EL,(DirType)64},
  1790. {0x0005FF57L,(DirType)64},
  1791. {0x0003FF62L,(DirType)64},
  1792. {0x0001FF6DL,(DirType)64},
  1793. {0x0000FF77L,(DirType)64},
  1794. {0x0000FF80L,(DirType)64}, // Track jump check here.
  1795. {0x0000FF8BL,(DirType)64},
  1796. {0x0000FF95L,(DirType)64},
  1797. {0x0000FFA0L,(DirType)64},
  1798. {0x0000FFABL,(DirType)64},
  1799. {0x0000FFB5L,(DirType)64},
  1800. {0x0000FFC0L,(DirType)64},
  1801. {0x0000FFCBL,(DirType)64},
  1802. {0x0000FFD5L,(DirType)64},
  1803. {0x0000FFE0L,(DirType)64},
  1804. {0x0000FFEBL,(DirType)64},
  1805. {0x0000FFF5L,(DirType)64},
  1806. {0x00000000L,(DirType)64}
  1807. };
  1808. DriveClass::TrackType const DriveClass::Track7[] = {
  1809. {0x0006FFFFL,(DirType)0},
  1810. {0x000CFFFEL,(DirType)4},
  1811. {0x0011FFFCL,(DirType)8},
  1812. {0x0018FFFAL,(DirType)12},
  1813. {0x001FFFF6L,(DirType)16},
  1814. {0x0024FFF3L,(DirType)19},
  1815. {0x002BFFF0L,(DirType)22},
  1816. {0x0030FFFDL,(DirType)23},
  1817. {0x0035FFEBL,(DirType)24},
  1818. {0x0038FFE8L,(DirType)25},
  1819. {0x003CFFE6L,(DirType)26},
  1820. {0x0040FFE3L,(DirType)27},
  1821. {0x0043FFE0L,(DirType)28},
  1822. {0x0046FFDDL,(DirType)29},
  1823. {0x0043FFDFL,(DirType)30},
  1824. {0x0040FFE1L,(DirType)30},
  1825. {0x003CFFE3L,(DirType)30},
  1826. {0x0038FFE5L,(DirType)30},
  1827. {0x0035FFE7L,(DirType)31},
  1828. {0x0030FFE9L,(DirType)31},
  1829. {0x002BFFEBL,(DirType)31},
  1830. {0x0024FFEDL,(DirType)31},
  1831. {0x001FFFF1L,(DirType)31},
  1832. {0x0018FFF4L,(DirType)32},
  1833. {0x0011FFF7L,(DirType)32},
  1834. {0x000CFFFAL,(DirType)32},
  1835. {0x0006FFFDL,(DirType)32},
  1836. {0x00000000L,(DirType)32}
  1837. };
  1838. DriveClass::TrackType const DriveClass::Track8[] = {
  1839. {0x0003FFFCL,(DirType)32},
  1840. {0x0006FFF7L,(DirType)36},
  1841. {0x000AFFF1L,(DirType)40},
  1842. {0x000CFFEBL,(DirType)44},
  1843. {0x000DFFE4L,(DirType)46},
  1844. {0x000EFFDCL,(DirType)48},
  1845. {0x000FFFD5L,(DirType)50},
  1846. {0x0010FFD0L,(DirType)52},
  1847. {0x0011FFC9L,(DirType)54},
  1848. {0x0012FFC2L,(DirType)56},
  1849. {0x0011FFC0L,(DirType)58},
  1850. {0x0010FFC2L,(DirType)60},
  1851. {0x000EFFC9L,(DirType)62},
  1852. {0x000CFFCFL,(DirType)64},
  1853. {0x000AFFD5L,(DirType)64},
  1854. {0x0008FFDAL,(DirType)64},
  1855. {0x0006FFE2L,(DirType)64},
  1856. {0x0004FFE9L,(DirType)64},
  1857. {0x0002FFEFL,(DirType)64},
  1858. {0x0001FFF5L,(DirType)64},
  1859. {0x0000FFF9L,(DirType)64},
  1860. {0x00000000L,(DirType)64}
  1861. };
  1862. DriveClass::TrackType const DriveClass::Track9[] = {
  1863. {0xFFF50002L,(DirType)0},
  1864. {0xFFEB0004L,(DirType)2},
  1865. {0xFFE00006L,(DirType)4},
  1866. {0xFFD50009L,(DirType)6},
  1867. {0xFFCE000CL,(DirType)9},
  1868. {0xFFC8000FL,(DirType)11},
  1869. {0xFFC00012L,(DirType)13},
  1870. {0xFFB80015L,(DirType)16},
  1871. {0xFFC00012L,(DirType)18},
  1872. {0xFFC8000EL,(DirType)20},
  1873. {0xFFCE000AL,(DirType)22},
  1874. {0xFFD50004L,(DirType)24},
  1875. {0xFFDE0000L,(DirType)26},
  1876. {0xFFE9FFF8L,(DirType)28},
  1877. {0xFFEEFFF2L,(DirType)30},
  1878. {0xFFF5FFEBL,(DirType)32},
  1879. {0xFFFDFFE1L,(DirType)34},
  1880. {0x0002FFD8L,(DirType)36},
  1881. {0x0007FFD2L,(DirType)39},
  1882. {0x000BFFCBL,(DirType)41},
  1883. {0x0010FFC5L,(DirType)43},
  1884. {0x0013FFBEL,(DirType)45},
  1885. {0x0015FFB7L,(DirType)48},
  1886. {0x0013FFBEL,(DirType)50},
  1887. {0x0011FFC5L,(DirType)52},
  1888. {0x000BFFCCL,(DirType)54},
  1889. {0x0008FFD4L,(DirType)56},
  1890. {0x0005FFDFL,(DirType)58},
  1891. {0x0003FFEBL,(DirType)62},
  1892. {0x0001FFF5L,(DirType)64},
  1893. {0x00000000L,(DirType)64}
  1894. };
  1895. DriveClass::TrackType const DriveClass::Track10[] = {
  1896. {0xFFF6000BL,(DirType)32},
  1897. {0xFFF00015L,(DirType)37},
  1898. {0xFFEB0020L,(DirType)42},
  1899. {0xFFE9002BL,(DirType)47},
  1900. {0xFFE50032L,(DirType)52},
  1901. {0xFFE30038L,(DirType)57},
  1902. {0xFFE00040L,(DirType)60},
  1903. {0xFFE20038L,(DirType)62},
  1904. {0xFFE40032L,(DirType)64},
  1905. {0xFFE5002AL,(DirType)68},
  1906. {0xFFE6001EL,(DirType)70},
  1907. {0xFFE70015L,(DirType)72},
  1908. {0xFFE8000BL,(DirType)74},
  1909. {0xFFE90000L,(DirType)76},
  1910. {0xFFE8FFF5L,(DirType)78},
  1911. {0xFFE7FFEBL,(DirType)80},
  1912. {0xFFE6FFE0L,(DirType)82},
  1913. {0xFFE5FFD5L,(DirType)84},
  1914. {0xFFE4FFCEL,(DirType)86},
  1915. {0xFFE2FFC5L,(DirType)88},
  1916. {0xFFE0FFC0L,(DirType)90},
  1917. {0xFFE3FFC5L,(DirType)92},
  1918. {0xFFE5FFCEL,(DirType)94},
  1919. {0xFFE9FFD5L,(DirType)95},
  1920. {0xFFEBFFE0L,(DirType)96},
  1921. {0xFFF0FFEBL,(DirType)96},
  1922. {0xFFF6FFF5L,(DirType)96},
  1923. {0x00000000L,(DirType)96}
  1924. };
  1925. DriveClass::TrackType const DriveClass::Track11[] = {
  1926. {0x01000000L,DIR_SW},
  1927. {0x00F30008L,DIR_SW},
  1928. {0x00E50010L,DIR_SW_X1},
  1929. {0x00D60018L,DIR_SW_X1},
  1930. {0x00C80020L,DIR_SW_X1},
  1931. {0x00B90028L,DIR_SW_X1},
  1932. {0x00AB0030L,DIR_SW_X2},
  1933. {0x009C0038L,DIR_SW_X2},
  1934. {0x008D0040L,DIR_SW_X2},
  1935. {0x007F0048L,DIR_SW_X2},
  1936. {0x00710050L,DIR_SW_X2},
  1937. {0x00640058L,DIR_SW_X2},
  1938. {0x00550060L,DIR_SW_X2},
  1939. {0x00000000L,DIR_SW_X2}
  1940. };
  1941. DriveClass::TrackType const DriveClass::Track12[] = {
  1942. {0xFF550060L,DIR_SW_X2},
  1943. {0xFF640058L,DIR_SW_X2},
  1944. {0xFF710050L,DIR_SW_X2},
  1945. {0xFF7F0048L,DIR_SW_X2},
  1946. {0xFF8D0040L,DIR_SW_X2},
  1947. {0xFF9C0038L,DIR_SW_X2},
  1948. {0xFFAB0030L,DIR_SW_X2},
  1949. {0xFFB90028L,DIR_SW_X1},
  1950. {0xFFC80020L,DIR_SW_X1},
  1951. {0xFFD60018L,DIR_SW_X1},
  1952. {0xFFE50010L,DIR_SW_X1},
  1953. {0xFFF30008L,DIR_SW},
  1954. {0x00000000L,DIR_SW}
  1955. };
  1956. #if(1)
  1957. /*
  1958. ** Drive out of weapon's factory.
  1959. */
  1960. DriveClass::TrackType const DriveClass::Track13[] = {
  1961. {XYP_COORD(0,-35),DIR_S},
  1962. {XYP_COORD(0,-34),DIR_S},
  1963. {XYP_COORD(0,-33),DIR_S},
  1964. {XYP_COORD(0,-32),DIR_S},
  1965. {XYP_COORD(0,-31),DIR_S},
  1966. {XYP_COORD(0,-30),DIR_S},
  1967. {XYP_COORD(0,-29),DIR_S},
  1968. {XYP_COORD(0,-28),DIR_S},
  1969. {XYP_COORD(0,-27),DIR_S},
  1970. {XYP_COORD(0,-26),DIR_S},
  1971. {XYP_COORD(0,-25),DIR_S},
  1972. {XYP_COORD(0,-24),DIR_S},
  1973. {XYP_COORD(0,-23),DIR_S},
  1974. {XYP_COORD(0,-22),DIR_S},
  1975. {XYP_COORD(0,-21),DIR_S},
  1976. {XYP_COORD(0,-20),DIR_S},
  1977. {XYP_COORD(0,-19),DIR_S},
  1978. {XYP_COORD(0,-18),DIR_S},
  1979. {XYP_COORD(0,-17),DIR_S},
  1980. {XYP_COORD(0,-16),DIR_S},
  1981. {XYP_COORD(0,-15),DIR_S},
  1982. {XYP_COORD(0,-14),DIR_S},
  1983. {XYP_COORD(0,-13),DIR_S},
  1984. {XYP_COORD(0,-12),DIR_S},
  1985. {XYP_COORD(0,-11),DIR_S},
  1986. {XYP_COORD(0,-10),DIR_S},
  1987. {XYP_COORD(0,-9),DIR_S},
  1988. {XYP_COORD(0,-8),DIR_S},
  1989. {XYP_COORD(0,-7),DIR_S},
  1990. {XYP_COORD(0,-6),DIR_S},
  1991. {XYP_COORD(0,-5),DIR_S},
  1992. {XYP_COORD(0,-4),DIR_S},
  1993. {XYP_COORD(0,-3),DIR_S},
  1994. {XYP_COORD(0,-2),DIR_S},
  1995. {XYP_COORD(0,-1),DIR_S},
  1996. {0x00000000L,DIR_S}
  1997. };
  1998. #else
  1999. /*
  2000. ** Drive out of weapon's factory.
  2001. */
  2002. DriveClass::TrackType const DriveClass::Track13[] = {
  2003. {XYP_COORD(10,-21),(DirType)(DIR_SW-10)},
  2004. {XYP_COORD(10,-21),(DirType)(DIR_SW-10)},
  2005. {XYP_COORD(10,-20),(DirType)(DIR_SW-10)},
  2006. {XYP_COORD(10,-20),(DirType)(DIR_SW-10)},
  2007. {XYP_COORD(9,-18),(DirType)(DIR_SW-10)},
  2008. {XYP_COORD(9,-18),(DirType)(DIR_SW-10)},
  2009. {XYP_COORD(9,-17),(DirType)(DIR_SW-10)},
  2010. {XYP_COORD(8,-16),(DirType)(DIR_SW-10)},
  2011. {XYP_COORD(8,-15),(DirType)(DIR_SW-10)},
  2012. {XYP_COORD(7,-14),(DirType)(DIR_SW-10)},
  2013. {XYP_COORD(7,-13),(DirType)(DIR_SW-10)},
  2014. {XYP_COORD(6,-12),(DirType)(DIR_SW-10)},
  2015. {XYP_COORD(6,-11),(DirType)(DIR_SW-10)},
  2016. {XYP_COORD(5,-10),(DirType)(DIR_SW-10)},
  2017. {XYP_COORD(5,-9),(DirType)(DIR_SW-10)},
  2018. {XYP_COORD(4,-8),(DirType)(DIR_SW-10)},
  2019. {XYP_COORD(4,-7),(DirType)(DIR_SW-10)},
  2020. {XYP_COORD(3,-6),(DirType)(DIR_SW-10)},
  2021. {XYP_COORD(3,-5),(DirType)(DIR_SW-9)},
  2022. {XYP_COORD(2,-4),(DirType)(DIR_SW-7)},
  2023. {XYP_COORD(2,-3),(DirType)(DIR_SW-5)},
  2024. {XYP_COORD(1,-2),(DirType)(DIR_SW-3)},
  2025. {XYP_COORD(1,-1),(DirType)(DIR_SW-1)},
  2026. {0x00000000L,DIR_SW}
  2027. };
  2028. #endif
  2029. /*
  2030. ** There are a limited basic number of tracks that a vehicle can follow. These
  2031. ** are they. Each track can be interpreted differently but this is controlled
  2032. ** by the TrackControl structure elaborated elsewhere.
  2033. */
  2034. DriveClass::RawTrackType const DriveClass::RawTracks[13] = {
  2035. {Track1, -1, 0, -1},
  2036. {Track2, -1, 0, -1},
  2037. {Track3, 37, 12, 22},
  2038. {Track4, 26, 11, 19},
  2039. {Track5, 45, 15, 31},
  2040. {Track6, 44, 16, 27},
  2041. {Track7, -1, 0, -1},
  2042. {Track8, -1, 0, -1},
  2043. {Track9, -1, 0, -1},
  2044. {Track10, -1, 0, -1},
  2045. {Track11, -1, 0, -1},
  2046. {Track12, -1, 0, -1},
  2047. {Track13, -1, 0, -1}
  2048. };
  2049. /***************************************************************************
  2050. ** Smooth turning control table. Given two directions in a path list, this
  2051. ** table determines which track to use and what modifying operations need
  2052. ** be performed on the track data.
  2053. */
  2054. DriveClass::TurnTrackType const DriveClass::TrackControl[67] = {
  2055. {1, 0, DIR_N, F_}, // 0-0
  2056. {3, 7, DIR_NE, F_D}, // 0-1 (raw chart)
  2057. {4, 9, DIR_E, F_D}, // 0-2 (raw chart)
  2058. {0, 0, DIR_SE, F_}, // 0-3 !
  2059. {0, 0, DIR_S, F_}, // 0-4 !
  2060. {0, 0, DIR_SW, F_}, // 0-5 !
  2061. {4, 9, DIR_W, (DriveClass::TrackControlType)(F_X|F_D)}, // 0-6
  2062. {3, 7, DIR_NW, (DriveClass::TrackControlType)(F_X|F_D)}, // 0-7
  2063. {6, 8, DIR_N, (DriveClass::TrackControlType)(F_T|F_X|F_Y|F_D)}, // 1-0
  2064. {2, 0, DIR_NE, F_}, // 1-1 (raw chart)
  2065. {6, 8, DIR_E, F_D}, // 1-2 (raw chart)
  2066. {5, 10, DIR_SE, F_D}, // 1-3 (raw chart)
  2067. {0, 0, DIR_S, F_}, // 1-4 !
  2068. {0, 0, DIR_SW, F_}, // 1-5 !
  2069. {0, 0, DIR_W, F_}, // 1-6 !
  2070. {5, 10, DIR_NW, (DriveClass::TrackControlType)(F_T|F_X|F_Y|F_D)}, // 1-7
  2071. {4, 9, DIR_N, (DriveClass::TrackControlType)(F_T|F_X|F_Y|F_D)}, // 2-0
  2072. {3, 7, DIR_NE, (DriveClass::TrackControlType)(F_T|F_X|F_Y|F_D)}, // 2-1
  2073. {1, 0, DIR_E, (DriveClass::TrackControlType)(F_T|F_X)}, // 2-2
  2074. {3, 7, DIR_SE, (DriveClass::TrackControlType)(F_T|F_X|F_D)}, // 2-3
  2075. {4, 9, DIR_S, (DriveClass::TrackControlType)(F_T|F_X|F_D)}, // 2-4
  2076. {0, 0, DIR_SW, F_}, // 2-5 !
  2077. {0, 0, DIR_W, F_}, // 2-6 !
  2078. {0, 0, DIR_NW, F_}, // 2-7 !
  2079. {0, 0, DIR_N, F_}, // 3-0 !
  2080. {5, 10, DIR_NE, (DriveClass::TrackControlType)(F_Y|F_D)}, // 3-1
  2081. {6, 8, DIR_E, (DriveClass::TrackControlType)(F_Y|F_D)}, // 3-2
  2082. {2, 0, DIR_SE, F_Y}, // 3-3
  2083. {6, 8, DIR_S, (DriveClass::TrackControlType)(F_T|F_X|F_D)}, // 3-4
  2084. {5, 10, DIR_SW, (DriveClass::TrackControlType)(F_T|F_X|F_D)}, // 3-5
  2085. {0, 0, DIR_W, F_}, // 3-6 !
  2086. {0, 0, DIR_NW, F_}, // 3-7 !
  2087. {0, 0, DIR_N, F_}, // 4-0 !
  2088. {0, 0, DIR_NE, F_}, // 4-1 !
  2089. {4, 9, DIR_E, (DriveClass::TrackControlType)(F_Y|F_D)}, // 4-2
  2090. {3, 7, DIR_SE, (DriveClass::TrackControlType)(F_Y|F_D)}, // 4-3
  2091. {1, 0, DIR_S, F_Y}, // 4-4
  2092. {3, 7, DIR_SW, (DriveClass::TrackControlType)(F_X|F_Y|F_D)}, // 4-5
  2093. {4, 9, DIR_W, (DriveClass::TrackControlType)(F_X|F_Y|F_D)}, // 4-6
  2094. {0, 0, DIR_NW, F_}, // 4-7 !
  2095. {0, 0, DIR_N, F_}, // 5-0 !
  2096. {0, 0, DIR_NE, F_}, // 5-1 !
  2097. {0, 0, DIR_E, F_}, // 5-2 !
  2098. {5, 10, DIR_SE, (DriveClass::TrackControlType)(F_T|F_D)}, // 5-3
  2099. {6, 8, DIR_S, (DriveClass::TrackControlType)(F_T|F_D)}, // 5-4
  2100. {2, 0, DIR_SW, F_T}, // 5-5
  2101. {6, 8, DIR_W, (DriveClass::TrackControlType)(F_X|F_Y|F_D)}, // 5-6
  2102. {5, 10, DIR_NW, (DriveClass::TrackControlType)(F_X|F_Y|F_D)}, // 5-7
  2103. {4, 9, DIR_N, (DriveClass::TrackControlType)(F_T|F_Y|F_D)}, // 6-0
  2104. {0, 0, DIR_NE, F_}, // 6-1 !
  2105. {0, 0, DIR_E, F_}, // 6-2 !
  2106. {0, 0, DIR_SE, F_}, // 6-3 !
  2107. {4, 9, DIR_S, (DriveClass::TrackControlType)(F_T|F_D)}, // 6-4
  2108. {3, 7, DIR_SW, (DriveClass::TrackControlType)(F_T|F_D)}, // 6-5
  2109. {1, 0, DIR_W, F_T}, // 6-6
  2110. {3, 7, DIR_NW, (DriveClass::TrackControlType)(F_T|F_Y|F_D)}, // 6-7
  2111. {6, 8, DIR_N, (DriveClass::TrackControlType)(F_T|F_Y|F_D)}, // 7-0
  2112. {5, 10, DIR_NE, (DriveClass::TrackControlType)(F_T|F_Y|F_D)}, // 7-1
  2113. {0, 0, DIR_E, F_}, // 7-2 !
  2114. {0, 0, DIR_SE, F_}, // 7-3 !
  2115. {0, 0, DIR_S, F_}, // 7-4 !
  2116. {5, 10, DIR_SW, (DriveClass::TrackControlType)(F_X|F_D)}, // 7-5
  2117. {6, 8, DIR_W, (DriveClass::TrackControlType)(F_X|F_D)}, // 7-6
  2118. {2, 0, DIR_NW, F_X}, // 7-7
  2119. {11, 11, DIR_SW, F_}, // Backup harvester into refinery.
  2120. {12, 12, DIR_SW_X2, F_}, // Drive back into refinery.
  2121. {13, 13, DIR_SW, F_} // Drive out of weapons factory.
  2122. };