OF_HARB.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OF_HARB.H
  21. //Description : Header of Firm Harbor
  22. #ifndef __OF_HARB_H
  23. #define __OF_HARB_H
  24. #ifndef __OFIRM_H
  25. #include <OFIRM.h>
  26. #endif
  27. //----------- Define constant --------------//
  28. #define MAX_SHIP_IN_HARBOR 4 // maximum no. of ships in a harbor
  29. #define MAX_BUILD_SHIP_QUEUE 10
  30. //------- Define class FirmHarbor --------//
  31. class UnitMarine;
  32. #pragma pack(1)
  33. class FirmHarbor : public Firm
  34. {
  35. public:
  36. short ship_recno_array[MAX_SHIP_IN_HARBOR];
  37. short ship_count;
  38. short build_unit_id; // race id. of the unit the town is currently building, 0-if currently not building any
  39. DWORD start_build_frame_no;
  40. char build_queue_array[MAX_BUILD_SHIP_QUEUE]; // it stores the unit id.
  41. char build_queue_count;
  42. UCHAR land_region_id;
  43. UCHAR sea_region_id;
  44. //----------- for harbor trading ------------//
  45. char link_checked; // similar to ai_link_checked, but this parameter can be used for players' nation
  46. char linked_mine_num;
  47. char linked_factory_num;
  48. char linked_market_num;
  49. short linked_mine_array[MAX_LINKED_FIRM_FIRM];
  50. short linked_factory_array[MAX_LINKED_FIRM_FIRM];
  51. short linked_market_array[MAX_LINKED_FIRM_FIRM];
  52. int total_linked_trade_firm()
  53. { return linked_mine_num + linked_factory_num + linked_market_num; }
  54. public:
  55. FirmHarbor();
  56. void init(int xLoc, int yLoc, int nationRecno, int firmId, char* buildCode=NULL, short builderRecno=0);
  57. void deinit_derived();
  58. void put_info(int refreshFlag);
  59. void detect_info();
  60. void assign_unit(int unitRecno);
  61. void next_day();
  62. int is_operating() { return 1; }
  63. int can_build_ship() { return !build_unit_id; }
  64. void build_ship(int unitId, char remoteAction);
  65. void sail_ship(int unitRecno, char remoteAction);
  66. void del_hosted_ship(int delUnitRecno);
  67. //-------- for harbor trading ----------//
  68. char get_linked_mine_num() { return linked_mine_num; }
  69. char get_linked_factory_num() { return linked_factory_num; }
  70. char get_linked_market_num() { return linked_market_num; }
  71. void update_linked_firm_info();
  72. //----------- AI functions -------------//
  73. void process_ai();
  74. void think_build_ship();
  75. void think_build_firm();
  76. int ai_build_firm(int firmId);
  77. int think_trade();
  78. UnitMarine* ai_get_free_trade_ship();
  79. //--------------------------------------//
  80. virtual FirmHarbor* cast_to_FirmHarbor() { return this; };
  81. void add_queue(int unitId);
  82. void remove_queue(int unitId);
  83. void cancel_build_unit();
  84. //-------------- multiplayer checking codes ---------------//
  85. virtual UCHAR crc8();
  86. virtual void clear_ptr();
  87. private:
  88. int should_show_harbor_info();
  89. void disp_main_menu(int refreshFlag);
  90. void detect_main_menu();
  91. void disp_build_menu(int refreshFlag);
  92. void disp_build_button(int y, int unitId, int buttonUp);
  93. void disp_queue_button(int y, int unitId, int buttonUp);
  94. void detect_build_menu();
  95. void put_det(int refreshFlag);
  96. int detect_det();
  97. void disp_ship_goods(UnitMarine* shipUnit, int dispY1, int refreshFlag);
  98. void disp_ship_units(UnitMarine* shipUnit, int dispY1, int refreshFlag);
  99. void disp_build_info(int refreshFlag);
  100. void add_hosted_ship(int shipRecno);
  101. void process_build();
  102. void process_queue();
  103. void repair_ship();
  104. };
  105. #pragma pack()
  106. //--------------------------------------//
  107. #endif