Prototype.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /***********************************************************************
  2. *
  3. * SPACE TRADER 1.2.0
  4. *
  5. * Prototype.h
  6. *
  7. * Copyright (C) 2000-2002 Pieter Spronck, All Rights Reserved
  8. *
  9. * Additional coding by Sam Anderson (rulez2@home.com)
  10. * Additional coding by Samuel Goldstein (palm@fogbound.net)
  11. *
  12. * Some code of Matt Lee's Dope Wars program has been used.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  27. *
  28. * You can contact the author at space_trader@hotmail.com
  29. *
  30. * For those who are familiar with the classic game Elite: many of the
  31. * ideas in Space Trader are heavily inspired by Elite.
  32. *
  33. **********************************************************************/
  34. // Prototype.h
  35. // All Function prototypes are defined here and can be referenced
  36. // from any source file. Functions are referenced from multiple
  37. // sources.
  38. // Shipyard.c
  39. extern void BuyRepairs( int _Amount );
  40. extern Boolean ShipYardFormHandleEvent( EventPtr eventP );
  41. extern long GetHullStrength( void );
  42. // Math.c
  43. extern int sqrt( int _a );
  44. extern long SqrDistance( SOLARSYSTEM _a, SOLARSYSTEM _b );
  45. extern long RealDistance( SOLARSYSTEM _a, SOLARSYSTEM _b );
  46. extern UInt16 Rand();
  47. extern void RandSeed( UInt16 _seed1, UInt16 _seed2 );
  48. extern int GetRandom2(int _maxVal);
  49. // Money.c
  50. extern long CurrentWorth();
  51. extern void PayInterest();
  52. // Field.c
  53. extern Handle SetField( FormPtr _frm, int _Nr, char* _Value, int _Size, Boolean _Focus );
  54. extern void GetField( FormPtr _frm, int _Nr, char* _Value, Handle _AmountH );
  55. extern void SetCheckBox( FormPtr _frm, int _Nr, Boolean _Value );
  56. extern Boolean GetCheckBox( FormPtr _frm, int _Nr );
  57. extern void SetTriggerList( FormPtr _frm, int _Nr, int _Index );
  58. extern int GetTriggerList( FormPtr _frm, int _Nr);
  59. extern void SetControlLabel( FormPtr _frm, int _Nr, Char * _Label );
  60. // Fuel.c
  61. extern char GetFuelTanks();
  62. extern char GetFuel();
  63. extern void BuyFuel( int _Amount );
  64. // Skill.c
  65. extern char TraderSkill( SHIP* _Sh );
  66. extern void RecalculateBuyPrices(Byte SystemID);
  67. extern void IncreaseRandomSkill();
  68. extern void TonicTweakRandomSkill();
  69. extern char FighterSkill( SHIP* _Sh );
  70. extern char PilotSkill( SHIP* _Sh );
  71. extern char EngineerSkill( SHIP* _Sh );
  72. extern char AdaptDifficulty( char _Level );
  73. extern void RecalculateSellPrices();
  74. extern char RandomSkill();
  75. extern Boolean HasGadget( SHIP* _Sh, char _Gg );
  76. extern Boolean HasShield( SHIP* _Sh, char _Gg );
  77. extern Boolean HasWeapon( SHIP* _Sh, char _Gg, Boolean _exactMatch );
  78. extern Byte NthLowestSkill( SHIP* _Sh, Byte _n );
  79. extern int DifficultyRange(int _low, int _high);
  80. // Draw.c
  81. extern void DrawShortRange( int _Index );
  82. extern void DrawCircle( int _Xs, int _Ys, int _R );
  83. extern void DrawGalaxy( int _Index );
  84. extern ControlPtr RectangularButton( FormPtr _frmP, int _Nr );
  85. extern void SBufMultiples( long _Count, char* _Txt );
  86. extern void SBufShortMultiples( long _Count, char* _Txt );
  87. extern void setFormTitle( int _formID, CharPtr _s );
  88. extern void setCurrentWinTitle( CharPtr _s );
  89. extern void setLabelText( FormPtr _frm, int _labelid, CharPtr _s );
  90. extern void RectangularShortcuts( FormPtr _frm, int _First );
  91. extern void EraseRectangle( int _x, int _y, int _ex, int _ey );
  92. extern void DrawChars( char* _Text, int _x, int _y );
  93. extern void DrawCharsCentered( char* _Text, int _y, Boolean _useBold );
  94. extern int ScrollButton( EventPtr _eventP );
  95. extern Boolean DisplayHeadline(char* _text, int* _y_coord);
  96. extern void DisplayPage(char* _text, int _start_y);
  97. // Cargo.c
  98. // Note the following four functions must stay together
  99. // These functions use QtyBuf which cannot be referenced externally
  100. // in it's current form.
  101. // ------------------------------------------------------------------
  102. extern void DisplayTradeQuantity( int Line, int Qty, int FirstQtyButton );
  103. extern Boolean PlunderFormHandleEvent( EventPtr eventP );
  104. extern Boolean BuyCargoFormHandleEvent(EventPtr eventP);
  105. extern Boolean SellCargoFormHandleEvent( EventPtr eventP );
  106. // ------------------------------------------------------------------
  107. extern int GetAmountToBuy( int Index ); // used in Traveler.c also
  108. extern void PlunderCargo( int _Index, int _Amount );
  109. extern int GetAmountToPlunder( int _Index );
  110. extern void BuyCargo( int _Index, int _Amount, Boolean _DisplayInfo );
  111. extern void SellCargo( int _Index, int _Amount, Byte Operation );
  112. extern void DisplayTradeItemName( int _i, Byte Operation );
  113. extern int TotalCargoBays();
  114. extern int FilledCargoBays();
  115. extern void DisplayPlunderCargoBays();
  116. extern void BuyItem( char _Slots, int* _Item, long _Price, char* _Name, int _ItemIndex );
  117. extern long BasePrice( char _ItemTechLevel, long _Price );
  118. extern long BaseSellPrice( int _Index, long _Price );
  119. extern void DrawSellEquipment();
  120. extern void SBufBays( void );
  121. extern void DisplayTradeCargoBays();
  122. extern void DisplayTradeCredits();
  123. extern void DisplayDumpCredits();
  124. extern Boolean HasTradeableItems (SHIP *_sh, Byte _theSystem, Byte _Operation);
  125. extern int GetRandomTradeableItem (SHIP *_sh, Byte _Operation);
  126. // Encounter.c
  127. extern Boolean EncounterFormHandleEvent( EventPtr _eventP );
  128. extern long TotalWeapons( SHIP* _Sh, int _minWeapon, int _maxWeapon ); // used in Traveler also
  129. extern void ShowShip( SHIP* _Sh, int _offset, Boolean _commandersShip );
  130. extern void EscapeWithPod(); // used in IncDays for Reactor meltdown
  131. // Traveler.c
  132. extern Boolean AveragePricesFormHandleEvent( EventPtr _eventP );
  133. extern Boolean RetireDestroyedUtopiaFormHandleEvent( EventPtr _eventP, char _EndStatus );
  134. extern Boolean UtopiaFormHandleEvent( EventPtr _eventP );
  135. extern Boolean RetireFormHandleEvent( EventPtr _eventP );
  136. extern Boolean ExecuteWarpFormHandleEvent(EventPtr _eventP);
  137. extern Boolean AnyEmptySlots( SHIP* _ship );
  138. extern void DoWarp(Boolean _viaSingularity ); //referenced in WarpForm for the Singularity.
  139. extern void Travel();
  140. extern Boolean StartNewGame();
  141. extern Boolean WormholeExists( int _a, int _b );
  142. extern void Arrival();
  143. extern Boolean Cloaked( SHIP* _Sh, SHIP* _Opp );
  144. extern int GetFirstEmptySlot( char _Slots, int* _Item );
  145. extern void IncDays( int _Amount );
  146. extern void ViewHighScores( void );
  147. extern long GetScore( char EndStatus, int Days, long Worth, char Level ); // Traveler.c
  148. extern long InsuranceMoney();
  149. extern long ToSpend();
  150. // ShipPrice.c
  151. extern long EnemyShipPrice( SHIP* Sh );
  152. extern long CurrentShipPriceWithoutCargo( Boolean _ForInsurance );
  153. extern long CurrentShipPrice( Boolean _ForInsurance );
  154. // BuyShipEvent.c
  155. extern void CreateFlea();
  156. extern Boolean BuyShipFormHandleEvent( EventPtr _eventP );
  157. // SystemInfoEvent.c
  158. extern void DrawPersonnelRoster();
  159. extern Boolean SystemInformationFormHandleEvent( EventPtr _eventP );
  160. extern Boolean NewspaperFormHandleEvent( EventPtr _eventP );
  161. extern void addNewsEvent(int _eventFlag);
  162. extern void resetNewsEvents();
  163. extern Boolean isNewsEvent(int _eventFlag);
  164. extern void replaceNewsEvent(int _originalEventFlag, int _replacementEventFlag);
  165. extern int latestNewsEvent();
  166. // Merchant
  167. Boolean Savegame( int State );
  168. Boolean LoadGame( int State );
  169. GetBitmapWidth( BitmapPtr BmpPtr );
  170. int GetBitmapHeight( BitmapPtr BmpPtr );
  171. // Form Event Handlers
  172. extern void ShowMessage( char *str1, char* str2, char* str3, Boolean ShowAlways );
  173. extern void ShowDumpCargo( void );
  174. extern int OpenQuests( void );
  175. extern Boolean MainFormHandleEvent( EventPtr _eventP );
  176. extern Boolean NewCommanderFormHandleEvent( EventPtr _eventP);
  177. extern Boolean QuestsFormHandleEvent( EventPtr _eventP );
  178. extern Boolean GalacticChartFormHandleEvent( EventPtr _eventP );
  179. extern Boolean WarpFormHandleEvent( EventPtr _eventP );
  180. extern Boolean ExecuteWarpFormHandleEvent( EventPtr _eventP );
  181. extern Boolean BuyEquipmentFormHandleEvent( EventPtr eventP );
  182. extern Boolean SellEquipmentFormHandleEvent( EventPtr _eventP );
  183. extern Boolean ShiptypeInfoFormHandleEvent( EventPtr _eventP );
  184. extern Boolean PersonnelRosterFormHandleEvent( EventPtr _eventP );
  185. extern Boolean SpecialEventFormHandleEvent( EventPtr _eventP );
  186. extern Boolean CommanderStatusFormHandleEvent( EventPtr _eventP );
  187. extern Boolean BankFormHandleEvent( EventPtr _eventP );
  188. extern Boolean CurrentShipFormHandleEvent( EventPtr _eventP );
  189. extern Boolean RetireFormHandleEvent( EventPtr _eventP );
  190. extern Boolean UtopiaFormHandleEvent( EventPtr _eventP );
  191. extern Boolean DestroyedFormHandleEvent( EventPtr _eventP );
  192. extern Boolean AppHandleEvent( EventPtr _eventP);
  193. extern Boolean SpecialEventFormHandleEvent( EventPtr _eventP );
  194. extern Boolean SpecialCargoFormHandleEvent( EventPtr _eventP );
  195. extern Boolean DiscardCargoFormHandleEvent( EventPtr _eventP );
  196. // ----------------------------------------------------------
  197. // Static Functions and their locations
  198. // Function Name Module
  199. // ----------------------------------------------------------
  200. // Err AppStart(); // merchant.c
  201. // void AppStop(); // merchant.c
  202. // Boolean DockedFormDoCommand(Word _command); // AppHandleEvent.c
  203. // void ShowBank( void ) // Bank.c
  204. // long MaxLoan( void ) // Bank.c
  205. // void GetLoan( long _Loan ); // Bank.c
  206. // void PayBack( long _Cash ); // Bank.c
  207. // char AvailableQuarters( void ) // SystemInfoEvent.c
  208. // int GetForHire(); // SystemInfoEvent.c
  209. // void DrawMercenary( int Index, int y ) // SystemInfoEvent.c
  210. // static int GetForHire( void ) // SystemInfoEvent.c
  211. // long TotalShields( SHIP* _Sh ); // Encounter.c
  212. // long TotalShieldStrength( SHIP* _Sh ); // Encounter.c
  213. // void ShowShip(SHIP* _Sh, int _offset); // Encounter.c
  214. // Boolean ExecuteAttack( SHIP* _Attacker, SHIP* _Defender, Boolean _Flees, Boolean _CommanderUnderAttack ); // Encounter.c
  215. // int ExecuteAction( Boolean _CommanderFlees ); // Encounter.c
  216. // void Arrested(); // Encounter.c
  217. // void EscapeWithPod(); // Encounter.c
  218. // void Scoop(); // Encounter.c
  219. // void EncounterButtons( void ) // Encounter.c
  220. // void DetermineShipPrices(); // BuyShipEvent.c
  221. // void BuyShip( int _Index ); // BuyShipEvent.c
  222. // void CreateShip ( int _Index ); // BuyShipEvent.c
  223. // void NewCommanderDrawSkills(); // NewCmdrEvent.c
  224. // void ShowCommanderStatus(); // CmdrStatusEvent.c
  225. // void DisplaySkill( int Skill, int AdaptedSkill, FormPtr frmP, long Label ) // CmdrStatusEvent.c
  226. // void ShowAveragePrices(); // Traveler.c
  227. // void ShuffleStatus(); // Traveler.c
  228. // void DeterminePrices(Byte SystemID); // Traveler.c
  229. // void GenerateOpponent( char _Opp ); // Traveler.c
  230. // void ChangeQuantities(); // Traveler.c
  231. // void InitializeTradeitems( const int _Index ); // Traveler.c
  232. // void ShowExecuteWarp( void ); // Traveler.c
  233. // void InitHighScores (void); // Traveler.c
  234. // Err CreateEmptyHighscoreTable( void ); // Traveler.c
  235. // Err OpenDatabase( void ); // Traveler.c
  236. // void ClearHighScores( void ); // Traveler.c
  237. // long WormholeTax( int a, int b ) // Traveler.c
  238. // int MercenaryMoney(); // Traveler.c
  239. // extern long StandardPrice( char _Good, char _Size, char _Tech, char _Government, int _Resources ); // Traveler.c
  240. // int NextSystemWithinRange(int Current, Boolean Back); // Traveler.c
  241. // void DrawShortRange( int Index ) // WarpFormEvent.c
  242. // void DrawCircle( int Xs, int Ys, int R ) // WarpFormEvent.c
  243. // void DrawGalaxy( int Index ) // WarpFormEvent.c
  244. // int GetAmountToSell( int Index ) // Trader.c
  245. // int GetAmountForFuel( void ) // Shipyard.c
  246. // int GetAmountForRepairs( void ) // Shipyard.c
  247. // void ShowShipYard(); // Shipyard.c
  248. // void DrawItem( char* Name, int y, long Price ) // BuyEquipEvent.c