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 21 // Filename : OU_MARI.H 22 // Description : header file of sea unit 23 24 #ifndef __OU_MARI_H 25 #define __OU_MARI_H 26 27 #ifndef __OUNIT_H 28 #include <OUNIT.h> 29 #endif 30 31 #ifndef __F_MARK_H 32 #include <OF_MARK.h> 33 #endif 34 35 #ifndef __OU_CARA_H 36 #include <OU_CARA.h> 37 #endif 38 39 //------- Define constant ---------// 40 41 #define MAX_UNIT_IN_SHIP 9 42 #define MAX_STOP_FOR_SHIP 3 // Maximum no. of destination stations per train 43 #define MAX_SHIP_WAIT_TERM 8 // no. of term the ship is in the market to upload/download cargo 44 45 //---------- Define constant ------------// 46 47 enum { SHIP_MENU_UNIT, 48 SHIP_MENU_GOODS, 49 }; 50 51 //-------------- define extra_move_in_beach ------------// 52 53 enum { NO_EXTRA_MOVE = 0, 54 EXTRA_MOVING_IN, 55 EXTRA_MOVING_OUT, 56 EXTRA_MOVE_FINISH, 57 }; 58 59 //-------- Define struct ShipStop ----------// 60 #pragma pack(1) 61 struct ShipStop : public TradeStop 62 { 63 public: 64 int update_pick_up(char *enableFlag=NULL); 65 }; 66 #pragma pack() 67 68 struct UnitMarineCrc; 69 70 //------- Define class UnitMarine -------// 71 72 #pragma pack(1) 73 class UnitMarine : public Unit 74 { 75 public: 76 Sprite splash; 77 78 char menu_mode; // goods menu or units menu 79 char extra_move_in_beach; 80 char in_beach; 81 82 //------ vars for carrying units ------// 83 84 char selected_unit_id; 85 short unit_recno_array[MAX_UNIT_IN_SHIP]; 86 char unit_count; 87 88 //------ vars for carrying goods ------// 89 90 char journey_status; // 1 for not unload but can up load, 2 for unload but not up load 91 char dest_stop_id; // destination stop id. the stop which the train currently is moving towards 92 char stop_defined_num; // num of stop defined 93 char wait_count; // set to -1 to indicate only one stop is specified 94 95 short stop_x_loc; // the x location the unit entering the stop 96 short stop_y_loc; // the y location the unit entering the stop 97 98 char auto_mode; // indicate whether auto mode is on/off, 1 - on, 0 - off 99 short cur_firm_recno; // the recno of current firm the ship entered 100 short carry_goods_capacity; 101 102 ShipStop stop_array[MAX_STOP_FOR_SHIP]; // an array of firm_recno telling train stop stations 103 void update_stop_list(); 104 int get_next_stop_id(int curStopId); 105 106 void pre_process(); 107 void set_stop_pick_up(int stopId, int newPickUpType, int remoteAction); 108 void ship_in_firm(int autoMode=1); 109 void ship_on_way(); 110 int appear_in_firm_surround(int& xLoc, int& yLoc, Firm* firmPtr); 111 112 void get_harbor_linked_firm_info(); 113 void harbor_unload_goods(); 114 void harbor_unload_product(); 115 void harbor_unload_raw(); 116 117 void harbor_load_goods(); 118 void harbor_auto_load_goods(); 119 void harbor_load_product(int goodsId, int autoPickUp, int considerMode); 120 void harbor_load_raw(int goodsId, int autoPickUp, int considerMode); 121 122 short raw_qty_array[MAX_RAW]; 123 short product_raw_qty_array[MAX_PRODUCT]; 124 int total_carried_goods(); 125 126 //----------- vars for attacking ----------// 127 128 AttackInfo ship_attack_info; 129 uint8_t attack_mode_selected; 130 131 //-------------- vars for AI --------------// 132 133 int last_load_goods_date; 134 135 public: 136 UnitMarine(); 137 ~UnitMarine(); 138 139 //------ overloaded function -------// 140 141 void init(int unitId, int nationRecno, int rankId, int unitLoyalty, int startX= -1, int startY= -1); 142 void init_derived(); 143 144 void disp_info(int refreshFlag); 145 void detect_info(); 146 bool is_in_build_menu(); 147 148 int should_show_info(); 149 150 void draw(); 151 void draw_outlined(); 152 void update_abs_pos(SpriteFrame* =0); 153 154 float actual_damage(); 155 short wave_height(int =0); 156 157 int can_unload_unit(); 158 159 void load_unit(int unitRecno); 160 void unload_unit(int unitSeqId, char remoteAction); 161 void unload_all_units(char remoteAction); 162 int unloading_unit(int isAll, int unitSeqId=0); 163 void del_unit(int unitRecno); 164 int can_set_stop(int firmRecno); 165 166 void extra_move(); 167 void process_extra_move(); 168 169 void set_stop(int stopId, int stopXLoc, int stopYLoc, char remoteAction); 170 void del_stop(int stopId, char remoteAction); 171 void select_attack_weapon(); 172 173 int is_ai_all_stop(); 174 175 int can_resign(); 176 177 int read_derived_file(File *); 178 int write_derived_file(File *); 179 virtual void fix_attack_info(); // set attack_info_array appropriately 180 181 //------- ai functions --------// 182 183 void process_ai(); 184 int think_resign(); 185 void think_del_stop(); 186 void ai_sail_to_nearby_harbor(); 187 188 void ai_ship_being_attacked(int attackerUnitRecno); 189 190 //-------------- multiplayer checking codes ---------------// 191 192 virtual uint8_t crc8(); 193 virtual void clear_ptr(); 194 virtual void init_crc(UnitMarineCrc *c); 195 196 private: 197 void disp_unit_menu(int dispY1, int refreshFlag); 198 void detect_unit_menu(); 199 200 void disp_goods_menu(int dispY1, int refreshFlag); 201 void detect_goods_menu(); 202 203 void disp_stop(int dispY1, int refreshFlag); 204 void detect_stop(); 205 void disp_goods(int dispY1, int refreshFlag); 206 void disp_goods_select_button(int stopNum, int dispY1, int refreshFlag); 207 208 void disp_unit_list(int dispY1, int refreshFlag); 209 int detect_unit_list(); 210 void disp_unit_info(int dispY1, int refreshFlag); 211 212 int is_on_coast(); 213 }; 214 #pragma pack() 215 216 //---------------------------------------// 217 218 #endif 219