OF_HARB.cpp 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270
  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.CPP
  21. //Description : Firm Harbor
  22. #include <OINFO.h>
  23. #include <OVGA.h>
  24. #include <ODATE.h>
  25. #include <OHELP.h>
  26. #include <OMOUSE.h>
  27. #include <OSTR.h>
  28. #include <OSYS.h>
  29. #include <OFONT.h>
  30. #include <OBUTTON.h>
  31. #include <OBUTT3D.h>
  32. #include <OVBROWIF.h>
  33. #include <OTERRAIN.h>
  34. #include <OPOWER.h>
  35. #include <OREGIONS.h>
  36. #include <OU_MARI.h>
  37. #include <OGAME.h>
  38. #include <ONATION.h>
  39. #include <OF_HARB.h>
  40. #include <OREMOTE.h>
  41. #include <OBUTTCUS.h>
  42. #include <OSE.h>
  43. #include <OSERES.h>
  44. //------------- Define coordinations -----------//
  45. enum { SHIP_BROWSE_X1 = INFO_X1,
  46. SHIP_BROWSE_Y1 = INFO_Y1+54,
  47. SHIP_BROWSE_X2 = INFO_X2,
  48. SHIP_BROWSE_Y2 = SHIP_BROWSE_Y1+100
  49. };
  50. enum { SHIP_DET_X1 = INFO_X1,
  51. SHIP_DET_Y1 = SHIP_BROWSE_Y2+5,
  52. SHIP_DET_X2 = INFO_X2,
  53. SHIP_DET_Y2 = SHIP_DET_Y1+92
  54. };
  55. //---------- Define constant ------------//
  56. enum { HARBOR_MENU_MAIN,
  57. HARBOR_MENU_BUILD,
  58. };
  59. // ######## begin Gilbert 22/9 #######//
  60. #define BUILD_BUTTON_WIDTH 205
  61. #define BUILD_BUTTON_HEIGHT 48
  62. #define COUNT_BUTTON_OFFSET_X 160
  63. #define COUNT_BUTTON_OFFSET_Y 8
  64. // ######## end Gilbert 22/9 #######//
  65. #define COUNT_BUTTON_WIDTH 32
  66. #define COUNT_BUTTON_HEIGHT 32
  67. //----------- Define static variables ----------//
  68. static VBrowseIF browse_ship;
  69. static Button3D button_build, button_sail;
  70. static Button3D button_cancel_build;
  71. static ButtonGroup button_mode(2);
  72. // ###### begin Gilbert 20/9 #######//
  73. // static short button_unit_id[MAX_SHIP_TYPE];
  74. static ButtonCustom button_ship[MAX_SHIP_TYPE];
  75. static ButtonCustom button_queue_ship[MAX_SHIP_TYPE];
  76. // ###### end Gilbert 20/9 #######//
  77. static int added_count;
  78. static ButtonCustom button_cancel;
  79. static int last_ship_count;
  80. static FirmHarbor* firm_harbor_ptr;
  81. static char harbor_menu_mode;
  82. static char disable_refresh=0;
  83. static char ship_disp_mode=SHIP_MENU_UNIT;
  84. //----------- Define static functions ----------//
  85. static void put_ship_rec(int recNo, int x, int y, int refreshFlag);
  86. static void i_disp_build_button(ButtonCustom *button, int);
  87. static void i_disp_queue_button(ButtonCustom *button, int);
  88. //--------- Begin of function FirmHarbor::FirmHarbor ---------//
  89. //
  90. FirmHarbor::FirmHarbor()
  91. {
  92. ship_count = 0;
  93. build_unit_id = 0;
  94. build_queue_count = 0;
  95. land_region_id = 0;
  96. sea_region_id = 0;
  97. link_checked = 0;
  98. linked_mine_num = linked_factory_num = linked_market_num = 0;
  99. memset(linked_mine_array, 0, sizeof(short)*MAX_LINKED_FIRM_FIRM);
  100. memset(linked_factory_array, 0, sizeof(short)*MAX_LINKED_FIRM_FIRM);
  101. memset(linked_market_array, 0, sizeof(short)*MAX_LINKED_FIRM_FIRM);
  102. }
  103. //----------- End of function FirmHarbor::FirmHarbor -----------//
  104. //--------- Begin of function FirmHarbor::deinit_derived ---------//
  105. //
  106. void FirmHarbor::deinit_derived()
  107. {
  108. int shipUnitRecno;
  109. for( int i=ship_count ; i>0 ; i-- )
  110. {
  111. shipUnitRecno = ship_recno_array[i-1];
  112. //---- mobilize ships in the harbor ----//
  113. sail_ship( shipUnitRecno, COMMAND_AUTO );
  114. //--- if the ship does not sailed out due to no limit sea space, delete it ---//
  115. if( ship_count==i )
  116. {
  117. del_hosted_ship(shipUnitRecno);
  118. unit_array.del(shipUnitRecno);
  119. }
  120. }
  121. }
  122. //----------- End of function FirmHarbor::deinit_derived() -----------//
  123. //--------- Begin of function FirmHarbor::init ---------//
  124. //
  125. void FirmHarbor::init(int xLoc, int yLoc, int nationRecno, int firmId, char* buildCode, short builderRecno)
  126. {
  127. // ignore raceId and find north, south, west or east harbor
  128. if( world.get_loc(xLoc+1, yLoc+2)->can_build_harbor(1) )
  129. {
  130. // check north harbour
  131. Firm::init(xLoc, yLoc, nationRecno, firmId, "N", builderRecno);
  132. land_region_id = world.get_loc(xLoc+1, yLoc+2)->region_id;
  133. sea_region_id = world.get_loc(xLoc+1, yLoc)->region_id;
  134. }
  135. else if( world.get_loc(xLoc+1, yLoc)->can_build_harbor(1) )
  136. {
  137. // check south harbour
  138. Firm::init(xLoc, yLoc, nationRecno, firmId, "S", builderRecno);
  139. land_region_id = world.get_loc(xLoc+1, yLoc)->region_id;
  140. sea_region_id = world.get_loc(xLoc+1, yLoc+2)->region_id;
  141. }
  142. else if( world.get_loc(xLoc+2, yLoc+1)->can_build_harbor(1) )
  143. {
  144. // check west harbour
  145. Firm::init(xLoc, yLoc, nationRecno, firmId, "W", builderRecno);
  146. land_region_id = world.get_loc(xLoc+2, yLoc+1)->region_id;
  147. sea_region_id = world.get_loc(xLoc, yLoc+1)->region_id;
  148. }
  149. else if( world.get_loc(xLoc, yLoc+1)->can_build_harbor(1) )
  150. {
  151. // check east harbour
  152. Firm::init(xLoc, yLoc, nationRecno, firmId, "E", builderRecno);
  153. land_region_id = world.get_loc(xLoc, yLoc+1)->region_id;
  154. sea_region_id = world.get_loc(xLoc+2, yLoc+1)->region_id;
  155. }
  156. else
  157. {
  158. err_here();
  159. }
  160. region_id = land_region_id; // set region_id to land_region_id
  161. //------- update the harbor count of the regions ------//
  162. region_array.update_region_stat();
  163. }
  164. //----------- End of function FirmHarbor::init -----------//
  165. //------- Begin of function FirmHarbor::assign_unit -----------//
  166. //
  167. void FirmHarbor::assign_unit(int unitRecno)
  168. {
  169. //------- if this is a construction worker -------//
  170. if( unit_array[unitRecno]->skill.skill_id == SKILL_CONSTRUCTION )
  171. {
  172. set_builder(unitRecno);
  173. return;
  174. }
  175. //---------------------------------------//
  176. //if( ship_count==MAX_SHIP_IN_HARBOR )
  177. // return;
  178. if(ship_count + (build_unit_id>0) == MAX_SHIP_IN_HARBOR)
  179. return; // leave a room for the building unit
  180. add_hosted_ship(unitRecno);
  181. unit_array[unitRecno]->deinit_sprite();
  182. UnitMarine *unitPtr = (UnitMarine*) unit_array[unitRecno];
  183. unitPtr->extra_move_in_beach = NO_EXTRA_MOVE;
  184. unitPtr->deinit_sprite();
  185. //------------------------------------------------//
  186. if( firm_array.selected_recno == firm_recno )
  187. info.disp();
  188. }
  189. //--------- End of function FirmHarbor::assign_unit -----------//
  190. //--------- Begin of function FirmHarbor::next_day ---------//
  191. //
  192. void FirmHarbor::next_day()
  193. {
  194. //----- call next_day() of the base class -----//
  195. Firm::next_day();
  196. //------- process building -------//
  197. if( build_unit_id )
  198. process_build();
  199. else
  200. process_queue();
  201. //-*********** simulate ship movement ************-//
  202. //if(build_unit_id==0)
  203. // build_ship(UNIT_CARAVEL, 0);
  204. //-*********** simulate ship movement ************-//
  205. }
  206. //----------- End of function FirmHarbor::next_day -----------//
  207. //--------- Begin of function FirmHarbor::put_info ---------//
  208. //
  209. void FirmHarbor::put_info(int refreshFlag)
  210. {
  211. if( refreshFlag==INFO_REPAINT && !disable_refresh )
  212. harbor_menu_mode = HARBOR_MENU_MAIN;
  213. switch( harbor_menu_mode )
  214. {
  215. case HARBOR_MENU_MAIN:
  216. disp_main_menu(refreshFlag);
  217. break;
  218. case HARBOR_MENU_BUILD:
  219. disp_build_menu(refreshFlag);
  220. break;
  221. }
  222. }
  223. //----------- End of function FirmHarbor::put_info -----------//
  224. //--------- Begin of function FirmHarbor::detect_info ---------//
  225. //
  226. void FirmHarbor::detect_info()
  227. {
  228. switch( harbor_menu_mode )
  229. {
  230. case HARBOR_MENU_MAIN:
  231. detect_main_menu();
  232. break;
  233. case HARBOR_MENU_BUILD:
  234. detect_build_menu();
  235. break;
  236. }
  237. }
  238. //----------- End of function FirmHarbor::detect_info -----------//
  239. //--------- Begin of function FirmHarbor::disp_main_menu ---------//
  240. //
  241. void FirmHarbor::disp_main_menu(int refreshFlag)
  242. {
  243. firm_harbor_ptr = this;
  244. disp_basic_info(INFO_Y1, refreshFlag);
  245. if( !should_show_harbor_info() )
  246. return;
  247. //-------- display browser -----------//
  248. if( refreshFlag == INFO_REPAINT )
  249. {
  250. browse_ship.init( SHIP_BROWSE_X1, SHIP_BROWSE_Y1, SHIP_BROWSE_X2, SHIP_BROWSE_Y2,
  251. 0, 25, ship_count, put_ship_rec );
  252. browse_ship.open(1);
  253. put_det(INFO_REPAINT);
  254. }
  255. else
  256. {
  257. if( last_ship_count != ship_count )
  258. {
  259. last_ship_count = ship_count;
  260. info.disp();
  261. }
  262. else
  263. browse_ship.update(); // update only
  264. }
  265. last_ship_count = ship_count;
  266. //-------------------------------//
  267. if( !own_firm() )
  268. return;
  269. //-------- display buttons ---------//
  270. if( refreshFlag == INFO_REPAINT )
  271. {
  272. button_build.paint( SHIP_DET_X1, SHIP_DET_Y2+4, 'A', "MAKESHIP" );
  273. button_sail.paint ( SHIP_DET_X1+BUTTON_ACTION_WIDTH, SHIP_DET_Y2+4, 'A', "SAILOUT" );
  274. }
  275. if( ship_count > 0 )
  276. button_sail.enable();
  277. else
  278. button_sail.disable();
  279. //------ display the info of the ship under construction ------//
  280. disp_build_info(refreshFlag);
  281. }
  282. //----------- End of function FirmHarbor::disp_main_menu -----------//
  283. //--------- Begin of function FirmHarbor::detect_main_menu ---------//
  284. //
  285. void FirmHarbor::detect_main_menu()
  286. {
  287. firm_harbor_ptr = this;
  288. if( detect_basic_info() )
  289. return;
  290. if( !own_firm() )
  291. return;
  292. if( browse_ship.detect() )
  293. put_det(INFO_UPDATE);
  294. if( detect_det() )
  295. return;
  296. //------- detect the build button ---------//
  297. if( button_build.detect() )
  298. {
  299. harbor_menu_mode = HARBOR_MENU_BUILD;
  300. disable_refresh = 1; // static var for disp_info() only
  301. info.disp();
  302. disable_refresh = 0;
  303. }
  304. //-------- detect the sail button ---------//
  305. if( button_sail.detect() && browse_ship.recno() > 0 )
  306. sail_ship( ship_recno_array[browse_ship.recno()-1], COMMAND_PLAYER );
  307. //---------- detect cancel build button -----------//
  308. if(build_unit_id)
  309. {
  310. if(button_cancel_build.detect())
  311. {
  312. if( !remote.is_enable() )
  313. cancel_build_unit();
  314. else
  315. {
  316. short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_HARBOR_SKIP_SHIP, sizeof(short));
  317. shortPtr[0] = firm_recno;
  318. }
  319. }
  320. }
  321. }
  322. //----------- End of function FirmHarbor::detect_main_menu -----------//
  323. //------- Begin of function FirmHarbor::should_show_harbor_info -------//
  324. //
  325. int FirmHarbor::should_show_harbor_info()
  326. {
  327. if( should_show_info() )
  328. return 1;
  329. //--- if any of the ships in the harbor has the spies of the player ---//
  330. UnitMarine* unitMarine;
  331. for( int i=0 ; i<ship_count ; i++ )
  332. {
  333. unitMarine = (UnitMarine*) unit_array[ ship_recno_array[i] ];
  334. if( unitMarine->should_show_info() )
  335. return 1;
  336. }
  337. return 0;
  338. }
  339. //------- End of function FirmHarbor::should_show_harbor_info ---------//
  340. //--------- Begin of function FirmHarbor::put_det ---------//
  341. //
  342. void FirmHarbor::put_det(int refreshFlag)
  343. {
  344. if( refreshFlag == INFO_REPAINT )
  345. vga.d3_panel_up( SHIP_DET_X1, SHIP_DET_Y1, SHIP_DET_X2, SHIP_DET_Y2 );
  346. else
  347. vga.blt_buf( SHIP_DET_X1, SHIP_DET_Y1, SHIP_DET_X2, SHIP_DET_Y2, 0 );
  348. if( browse_ship.none_record )
  349. return;
  350. refreshFlag = INFO_REPAINT; // for calling disp_ship_units() and disp_ship_goods()
  351. //------- display info of the ship --------//
  352. UnitMarine* shipUnitPtr = (UnitMarine*) unit_array[ ship_recno_array[browse_ship.recno()-1] ];
  353. UnitInfo* shipUnitInfo = unit_res[shipUnitPtr->unit_id];
  354. //----- if the ship can carry both goods and units, display mode selection button ---//
  355. if( shipUnitInfo->carry_goods_capacity > 0 &&
  356. shipUnitInfo->carry_unit_capacity > 0 )
  357. {
  358. button_mode[0].create_text( SHIP_DET_X1+10, SHIP_DET_Y1+3, SHIP_DET_X1+80, SHIP_DET_Y1+19, "Units" );
  359. button_mode[1].create_text( SHIP_DET_X1+90, SHIP_DET_Y1+3, SHIP_DET_X2-10, SHIP_DET_Y1+19, "Goods" );
  360. button_mode.paint(ship_disp_mode);
  361. if( ship_disp_mode == SHIP_MENU_UNIT )
  362. disp_ship_units(shipUnitPtr, SHIP_DET_Y1+22, refreshFlag);
  363. else
  364. disp_ship_goods(shipUnitPtr, SHIP_DET_Y1+22, refreshFlag);
  365. }
  366. else if( shipUnitInfo->carry_goods_capacity > 0 )
  367. {
  368. disp_ship_goods(shipUnitPtr, SHIP_DET_Y1+22, refreshFlag);
  369. }
  370. else if( shipUnitInfo->carry_unit_capacity > 0 )
  371. {
  372. disp_ship_units(shipUnitPtr, SHIP_DET_Y1+22, refreshFlag);
  373. }
  374. }
  375. //----------- End of function FirmHarbor::put_det -----------//
  376. //--------- Begin of function FirmHarbor::detect_det ---------//
  377. //
  378. int FirmHarbor::detect_det()
  379. {
  380. if( browse_ship.none_record )
  381. return 0;
  382. UnitMarine* shipUnitPtr = (UnitMarine*) unit_array[ ship_recno_array[browse_ship.recno()-1] ];
  383. UnitInfo* shipUnitInfo = unit_res[shipUnitPtr->unit_id];
  384. if( shipUnitInfo->carry_goods_capacity > 0 &&
  385. shipUnitInfo->carry_unit_capacity > 0 )
  386. {
  387. if( button_mode.detect() >= 0 )
  388. {
  389. ship_disp_mode = button_mode.button_pressed;
  390. vga.blt_buf( SHIP_DET_X1, SHIP_DET_Y1+22, SHIP_DET_X2, SHIP_DET_Y2, 0 );
  391. put_det(INFO_UPDATE);
  392. return 1;
  393. }
  394. }
  395. return 0;
  396. }
  397. //----------- End of function FirmHarbor::detect_det -----------//
  398. //--------- Begin of function FirmHarbor::disp_ship_goods ---------//
  399. //
  400. // Display goods carried by the selected ship.
  401. //
  402. void FirmHarbor::disp_ship_goods(UnitMarine* shipUnit, int dispY1, int refreshFlag)
  403. {
  404. int x=INFO_X1+20, y=dispY1+5;
  405. String str;
  406. int i;
  407. for(i=0; i<MAX_RAW; i++, x+=60)
  408. {
  409. vga_front.d3_panel_up( x, y, x+RAW_SMALL_ICON_WIDTH+5, y+RAW_SMALL_ICON_HEIGHT+5 );
  410. raw_res.put_small_raw_icon( x+3, y+3, i+1 );
  411. font_san.disp( x+25, y+2, shipUnit->raw_qty_array[i], 1, x+59 );
  412. }
  413. x =INFO_X1+20;
  414. y+=19;
  415. for( i=0; i<MAX_PRODUCT; i++, x+=60)
  416. {
  417. vga_front.d3_panel_up( x, y, x+RAW_SMALL_ICON_WIDTH+5, y+RAW_SMALL_ICON_HEIGHT+5 );
  418. raw_res.put_small_product_icon( x+3, y+3, i+1 );
  419. font_san.disp( x+25, y+2, shipUnit->product_raw_qty_array[i], 1, x+59 );
  420. }
  421. }
  422. //---------- End of function FirmHarbor::disp_ship_goods ----------//
  423. //--------- Begin of function FirmHarbor::disp_ship_units ---------//
  424. //
  425. void FirmHarbor::disp_ship_units(UnitMarine* shipUnit, int dispY1, int refreshFlag)
  426. {
  427. //------ display population composition -------//
  428. int x, y;
  429. Unit* unitPtr;
  430. static short last_unit_race_array[MAX_UNIT_IN_SHIP];
  431. dispY1+=5;
  432. for( int i=0 ; i<MAX_UNIT_IN_SHIP ; i++ )
  433. {
  434. x = INFO_X1+10+i%5*37;
  435. y = dispY1+i/5*29;
  436. if( i<shipUnit->unit_count )
  437. {
  438. unitPtr = unit_array[ shipUnit->unit_recno_array[i] ];
  439. if( refreshFlag==INFO_REPAINT || last_unit_race_array[i] != unitPtr->race_id )
  440. {
  441. vga_front.d3_panel_up( x, y, x+27, y+23, 1 );
  442. // ####### begin Gilbert 17/10 ##########//
  443. vga_front.put_bitmap(x+2, y+2, unit_res[unitPtr->unit_id]->get_small_icon_ptr(unitPtr->rank_id));
  444. // ####### end Gilbert 17/10 ##########//
  445. }
  446. //------- set help parameters ---------//
  447. if( mouse.in_area(x, y, x+27, y+23) )
  448. help.set_unit_help( unitPtr->unit_id, 0, x, y, x+27, y+23 );
  449. //------------------------------------//
  450. last_unit_race_array[i] = unitPtr->race_id;
  451. }
  452. else
  453. {
  454. if( last_unit_race_array[i] != 0 )
  455. {
  456. vga.blt_buf( x-2, y-2, x+36, y+25, 0 );
  457. last_unit_race_array[i] = 0;
  458. }
  459. }
  460. }
  461. }
  462. //----------- End of function FirmHarbor::disp_ship_units -----------//
  463. //--------- Begin of function FirmHarbor::disp_build_menu ---------//
  464. //
  465. void FirmHarbor::disp_build_menu(int refreshFlag)
  466. {
  467. // ###### begin Gilbert 20/9 ######//
  468. if( refreshFlag == INFO_UPDATE )
  469. {
  470. for( int b=0; b<added_count; ++b )
  471. {
  472. button_ship[b].paint(-1, 0);
  473. // button_queue_ship[b] is called by button_ship[b].paint();
  474. }
  475. }
  476. else if( refreshFlag == INFO_REPAINT )
  477. {
  478. added_count=0;
  479. int unitId, x=INFO_X1, y=INFO_Y1;
  480. for( unitId=1; unitId<=MAX_UNIT_TYPE ; unitId++ )
  481. {
  482. if( unit_res[unitId]->unit_class == UNIT_CLASS_SHIP )
  483. {
  484. if( unit_res[unitId]->get_nation_tech_level(nation_recno) > 0 )
  485. {
  486. // disp_build_button( y, unitId, 1);
  487. button_queue_ship[added_count].create(x+COUNT_BUTTON_OFFSET_X, y+COUNT_BUTTON_OFFSET_Y,
  488. x+COUNT_BUTTON_OFFSET_X+COUNT_BUTTON_WIDTH-1, y+COUNT_BUTTON_OFFSET_Y+COUNT_BUTTON_HEIGHT-1,
  489. i_disp_queue_button, ButtonCustomPara(this, unitId) );
  490. button_ship[added_count].paint(x, y, x+BUILD_BUTTON_WIDTH-1, y+BUILD_BUTTON_HEIGHT-1,
  491. i_disp_build_button, ButtonCustomPara(&button_queue_ship[added_count], unitId) );
  492. err_when(added_count >= MAX_SHIP_TYPE);
  493. // button_unit_id[added_count++] = unitId;
  494. added_count++;
  495. y += BUILD_BUTTON_HEIGHT;
  496. }
  497. }
  498. }
  499. button_cancel.paint(x, y, x+BUILD_BUTTON_WIDTH-1, y+BUILD_BUTTON_HEIGHT*3/4,
  500. ButtonCustom::disp_text_button_func, ButtonCustomPara((void*)"Done",0) );
  501. }
  502. // ###### end Gilbert 20/9 ######//
  503. }
  504. //----------- End of function FirmHarbor::disp_build_menu -----------//
  505. // ####### begin Gilbert 20/9 ########//
  506. /*
  507. //--------- Begin of function FirmHarbor::disp_build_button ---------//
  508. void FirmHarbor::disp_build_button(int y, int unitId, int buttonUp)
  509. {
  510. int x;
  511. int y0 = y;
  512. if(buttonUp)
  513. {
  514. vga.d3_panel_up(INFO_X1, y, INFO_X2-1, y+BUILD_BUTTON_HEIGHT-2);
  515. x = INFO_X1;
  516. }
  517. else
  518. {
  519. vga.d3_panel_down(INFO_X1, y, INFO_X2-1, y+BUILD_BUTTON_HEIGHT-2);
  520. x = INFO_X1+1;
  521. y++;
  522. }
  523. // display unit large icon
  524. UnitInfo* unitInfo = unit_res[unitId];
  525. vga_front.put_bitmap(x+6, y+4, unitInfo->get_large_icon_ptr(0));
  526. //-------- display unit name --------//
  527. String str;
  528. str = unitInfo->name;
  529. font_bible.put( x+60, y+14, str );
  530. disp_queue_button(y0+COUNT_BUTTON_OFFSET_Y, unitId, 1);
  531. }
  532. //----------- End of function FirmHarbor::disp_build_button -----------//
  533. */
  534. //-------- Begin of function i_disp_build_button --------//
  535. //
  536. static void i_disp_build_button(ButtonCustom *button, int repaintBody)
  537. {
  538. int x1 = button->x1;
  539. int y1 = button->y1;
  540. int x2 = button->x2;
  541. int y2 = button->y2;
  542. if( !button->pushed_flag )
  543. {
  544. if( repaintBody )
  545. {
  546. vga.blt_buf(x1, y1, x2, y2, 0);
  547. vga.d3_panel2_up( x1, y1, x2, y2, 1 );
  548. }
  549. x2--;
  550. y2--;
  551. }
  552. else
  553. {
  554. if( repaintBody )
  555. {
  556. vga.blt_buf(x1, y1, x2, y2, 0);
  557. vga.d3_panel2_down( x1, y1, x2, y2, 1 );
  558. }
  559. x1++;
  560. y1++;
  561. }
  562. ButtonCustom *queueButton = (ButtonCustom *)button->custom_para.ptr;
  563. if( repaintBody)
  564. {
  565. // display unit large icon
  566. short unitId = button->custom_para.value;
  567. UnitInfo* unitInfo = unit_res[unitId];
  568. vga_front.put_bitmap(x1+6, y1+4, unitInfo->get_large_icon_ptr(0));
  569. err_when( button->custom_para.value != queueButton->custom_para.value);
  570. //-------- display unit name --------//
  571. String str;
  572. str = unitInfo->name;
  573. if( unitInfo->unit_class == UNIT_CLASS_WEAPON ) // add version no.
  574. {
  575. FirmHarbor *harbor = (FirmHarbor *)queueButton->custom_para.ptr;
  576. int techLevel = unitInfo->get_nation_tech_level(harbor->nation_recno);
  577. if( techLevel > 1 )
  578. {
  579. str += " ";
  580. str += m.roman_number(techLevel);
  581. }
  582. }
  583. font_bible.put( x1+60, y1+13, str );
  584. }
  585. // display small button
  586. queueButton->paint(-1, repaintBody);
  587. }
  588. //--------- End of static function i_disp_build_button ---------//
  589. /*
  590. //--------- Begin of function FirmHarbor::disp_queue_button ---------//
  591. void FirmHarbor::disp_queue_button(int y, int unitId, int buttonUp)
  592. {
  593. //----- count the no. of units queued for this ship ------//
  594. int x=INFO_X1+2+COUNT_BUTTON_OFFSET_X;
  595. int queuedCount=0;
  596. for(int i=0; i<build_queue_count; i++)
  597. {
  598. if(build_queue_array[i] == unitId)
  599. queuedCount++;
  600. }
  601. if(build_unit_id==unitId)
  602. queuedCount++;
  603. if(buttonUp)
  604. vga.d3_panel_up(x, y, x+COUNT_BUTTON_WIDTH-1, y+COUNT_BUTTON_HEIGHT-1);
  605. else
  606. {
  607. vga.d3_panel_down(x, y, x+COUNT_BUTTON_WIDTH-1, y+COUNT_BUTTON_HEIGHT-1);
  608. x++;
  609. y++;
  610. }
  611. font_san.center_put(x, y, x+COUNT_BUTTON_WIDTH-1 , y+COUNT_BUTTON_HEIGHT-1, m.format(queuedCount));
  612. }
  613. //----------- End of function FirmHarbor::disp_queue_button -----------//
  614. */
  615. //-------- Begin of static function i_disp_queue_button --------//
  616. //
  617. static void i_disp_queue_button(ButtonCustom *button, int repaintBody)
  618. {
  619. FirmHarbor *harbor= (FirmHarbor *)button->custom_para.ptr;
  620. int x1 = button->x1;
  621. int y1 = button->y1;
  622. int x2 = button->x2;
  623. int y2 = button->y2;
  624. if( !button->pushed_flag )
  625. {
  626. if( repaintBody )
  627. {
  628. vga.blt_buf(x1, y1, x2, y2, 0);
  629. vga.d3_panel2_up( x1, y1, x2, y2, 1, 1);
  630. }
  631. x2--;
  632. y2--;
  633. }
  634. else
  635. {
  636. if( repaintBody )
  637. {
  638. vga.blt_buf(x1, y1, x2, y2, 0);
  639. vga.d3_panel2_down( x1, y1, x2, y2, 1, 1);
  640. }
  641. x1++;
  642. y1++;
  643. }
  644. //----- count the no. of units queued for this weapon ------//
  645. short unitId = button->custom_para.value;
  646. int queuedCount=0;
  647. for( int i=0 ; i<harbor->build_queue_count ; i++ )
  648. {
  649. if( harbor->build_queue_array[i] == unitId )
  650. queuedCount++;
  651. }
  652. if( harbor->build_unit_id == unitId)
  653. queuedCount++;
  654. font_mid.center_put( x1+3, y1+3, x2-3, y2-3, m.format(queuedCount), 1);
  655. }
  656. //--------- End of static function i_disp_queue_button ---------//
  657. // ####### end Gilbert 20/9 #######//
  658. //--------- Begin of function FirmHarbor::detect_build_menu ---------//
  659. //
  660. void FirmHarbor::detect_build_menu()
  661. {
  662. int unitId, x=INFO_X1+2, y=INFO_Y1, rc, quitFlag;
  663. UnitInfo* unitInfo;
  664. for(int b=0; b<added_count; ++b)
  665. {
  666. // ###### begin Gilbert 20/9 #########//
  667. unitId = button_ship[b].custom_para.value;
  668. // ###### end Gilbert 20/9 #########//
  669. unitInfo = unit_res[unitId];
  670. //------ detect pressing on the small queue count button -------//
  671. // ####### begin Gilbert 20/9 ########//
  672. rc = 0;
  673. if( (rc = button_queue_ship[b].detect(0,0,2)) != 0 ) // both button
  674. {
  675. quitFlag = 0; // don't quit the menu right after pressing the button
  676. }
  677. //------ detect pressing on the big button -------//
  678. else if( (rc = button_ship[b].detect(0,0,2)) != 0 )
  679. {
  680. quitFlag = 1; // quit the menu right after pressing the button
  681. }
  682. // ####### end Gilbert 20/9 ########//
  683. //------- process the action --------//
  684. if( rc > 0 )
  685. {
  686. if( rc==1 ) // left button
  687. {
  688. if( remote.is_enable() )
  689. {
  690. // packet structure : <firm recno> <unit Id>
  691. short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_HARBOR_BUILD_SHIP, 2*sizeof(short) );
  692. shortPtr[0] = firm_recno;
  693. shortPtr[1] = unitId;
  694. }
  695. else
  696. add_queue(unitId);
  697. // ##### begin Gilbert 25/9 ######//
  698. se_ctrl.immediate_sound("TURN_ON");
  699. // ##### end Gilbert 25/9 ######//
  700. }
  701. else // right button - remove queue
  702. {
  703. if( remote.is_enable() )
  704. {
  705. // packet structure : <firm recno> <unit Id>
  706. short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_HARBOR_BUILD_SHIP, 2*sizeof(short) );
  707. shortPtr[0] = firm_recno;
  708. shortPtr[1] = -unitId;
  709. }
  710. else
  711. remove_queue(unitId);
  712. // ##### begin Gilbert 25/9 ######//
  713. se_ctrl.immediate_sound("TURN_OFF");
  714. // ##### end Gilbert 25/9 ######//
  715. }
  716. if( quitFlag )
  717. info.disp(); // info.disp() will call put_info() which will switch mode back to the main menu mode
  718. else
  719. // ######## begin Gilbert 20/9 ########//
  720. // disp_queue_button(y+COUNT_BUTTON_OFFSET_Y, unitId, 1);
  721. info.update();
  722. // ######## end Gilbert 20/9 ########//
  723. return;
  724. }
  725. y += BUILD_BUTTON_HEIGHT;
  726. }
  727. //------ detect the cancel button --------//
  728. if( button_cancel.detect() || mouse.any_click(1) ) // press the cancel button or right click
  729. {
  730. harbor_menu_mode = HARBOR_MENU_MAIN;
  731. info.disp();
  732. // ###### begin Gilbert 26/9 #######//
  733. se_ctrl.immediate_sound("TURN_OFF");
  734. // ###### end Gilbert 26/9 #######//
  735. }
  736. }
  737. //----------- End of function FirmHarbor::detect_build_menu -----------//
  738. //--------- Begin of function FirmHarbor::build_ship ---------//
  739. //
  740. void FirmHarbor::build_ship(int unitId, char)
  741. {
  742. if(ship_count>=MAX_SHIP_IN_HARBOR)
  743. return;
  744. Nation* nationPtr = nation_array[nation_recno];
  745. if( nationPtr->cash < unit_res[unitId]->build_cost )
  746. return;
  747. nationPtr->add_expense( EXPENSE_SHIP, unit_res[unitId]->build_cost);
  748. build_unit_id = unitId;
  749. start_build_frame_no = sys.frame_count;
  750. }
  751. //----------- End of function FirmHarbor::build_ship -----------//
  752. //--------- Begin of function FirmHarbor::sail_ship ---------//
  753. //
  754. void FirmHarbor::sail_ship(int unitRecno, char remoteAction)
  755. {
  756. if( !remoteAction && remote.is_enable() )
  757. {
  758. // packet structure : <firm recno> <browseRecno>
  759. short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_HARBOR_SAIL_SHIP, 2*sizeof(short) );
  760. shortPtr[0] = firm_recno;
  761. shortPtr[1] = unitRecno;
  762. return;
  763. }
  764. //----- get the browse recno of the ship in the harbor's ship_recno_array[] ----//
  765. int browseRecno=0;
  766. for( int i=0 ; i<ship_count ; i++ )
  767. {
  768. if( ship_recno_array[i] == unitRecno )
  769. {
  770. browseRecno = i+1;
  771. break;
  772. }
  773. }
  774. err_when( !browseRecno );
  775. // ###### begin Gilbert 10/11 ########//
  776. if( !browseRecno )
  777. return;
  778. // ###### end Gilbert 10/11 ########//
  779. //------------------------------------------------------------//
  780. Unit* unitPtr = unit_array[unitRecno];
  781. err_when( unitPtr->unit_mode != UNIT_MODE_IN_HARBOR || unitPtr->unit_mode_para != firm_recno );
  782. SpriteInfo* spriteInfo = unitPtr->sprite_info;
  783. int xLoc=loc_x1; // xLoc & yLoc are used for returning results
  784. int yLoc=loc_y1;
  785. if(!world.locate_space(xLoc, yLoc, loc_x2, loc_y2, spriteInfo->loc_width, spriteInfo->loc_height, UNIT_SEA, sea_region_id))
  786. return;
  787. unitPtr->init_sprite(xLoc, yLoc);
  788. del_hosted_ship(ship_recno_array[browseRecno-1]);
  789. //-------- selected the ship --------//
  790. if( firm_array.selected_recno == firm_recno &&
  791. nation_recno == nation_array.player_recno )
  792. {
  793. power.reset_selection();
  794. unitPtr->selected_flag = 1;
  795. unit_array.selected_recno = unitPtr->sprite_recno;
  796. unit_array.selected_count = 1;
  797. info.disp();
  798. }
  799. }
  800. //----------- End of function FirmHarbor::sail_ship -----------//
  801. //--------- Begin of function FirmHarbor::disp_build_info ---------//
  802. //
  803. void FirmHarbor::disp_build_info(int refreshFlag)
  804. {
  805. if( !build_unit_id || nation_recno!=nation_array.player_recno )
  806. return;
  807. int dispY1 = INFO_Y1+26;
  808. int x=MSG_X1+3, y=MSG_Y1+3;
  809. if( refreshFlag == INFO_REPAINT )
  810. {
  811. vga.d3_panel_up( MSG_X1, MSG_Y1, MSG_X2, MSG_Y2 );
  812. vga.d3_panel_down(x, y, x+UNIT_SMALL_ICON_WIDTH+3, y+UNIT_SMALL_ICON_HEIGHT+3 );
  813. vga_front.put_bitmap(x+2, y+2, unit_res[build_unit_id]->get_small_icon_ptr(RANK_SOLDIER) );
  814. }
  815. vga_front.indicator( 0, x+UNIT_SMALL_ICON_WIDTH+6, y,
  816. (float)(sys.frame_count-start_build_frame_no),
  817. (float)unit_res[build_unit_id]->build_days * FRAMES_PER_DAY, VGA_GRAY );
  818. button_cancel_build.paint(MSG_X2-27, MSG_Y1+2, "V_X-U", "V_X-D");
  819. button_cancel_build.set_help_code( "CANCELSHP" );
  820. }
  821. //----------- End of function FirmHarbor::disp_build_info -----------//
  822. //--------- Begin of function FirmHarbor::process_build ---------//
  823. //
  824. void FirmHarbor::process_build()
  825. {
  826. int totalBuildDays = unit_res[build_unit_id]->build_days;
  827. err_when( !build_unit_id );
  828. if( (int)(sys.frame_count-start_build_frame_no) / FRAMES_PER_DAY >= totalBuildDays )
  829. {
  830. int unitRecno = unit_array.add_unit( build_unit_id, nation_recno );
  831. add_hosted_ship(unitRecno);
  832. if( own_firm() )
  833. se_res.far_sound(center_x, center_y, 1, 'F', firm_id, "FINS", 'S', unit_res[build_unit_id]->sprite_id);
  834. build_unit_id = 0;
  835. // ##### begin Gilbert 20/9 ########//
  836. if( firm_array.selected_recno == firm_recno )
  837. {
  838. disable_refresh = 1;
  839. info.disp();
  840. disable_refresh = 0;
  841. }
  842. // ##### end Gilbert 20/9 ########//
  843. //-*********** simulate ship movement ************-//
  844. //sail_ship(ship_recno_array[0], 0);
  845. //-*********** simulate ship movement ************-//
  846. }
  847. }
  848. //----------- End of function FirmHarbor::process_build -----------//
  849. //--------- Begin of function FirmHarbor::cancel_build_unit ---------//
  850. void FirmHarbor::cancel_build_unit()
  851. {
  852. build_unit_id = 0;
  853. if( firm_array.selected_recno == firm_recno )
  854. {
  855. disable_refresh = 1;
  856. info.disp();
  857. disable_refresh = 0;
  858. }
  859. }
  860. //----------- End of function FirmHarbor::cancel_build_unit -----------//
  861. //--------- Begin of function FirmHarbor::add_hosted_ship ---------//
  862. //
  863. void FirmHarbor::add_hosted_ship(int shipRecno)
  864. {
  865. err_when( ship_count == MAX_SHIP_IN_HARBOR );
  866. ship_recno_array[ship_count++] = shipRecno;
  867. //---- set the unit_mode of the ship ----//
  868. err_when( firm_id != FIRM_HARBOR );
  869. unit_array[shipRecno]->set_mode(UNIT_MODE_IN_HARBOR, firm_recno);
  870. //---------------------------------------//
  871. if( firm_recno == firm_array.selected_recno )
  872. put_info(INFO_UPDATE);
  873. }
  874. //----------- End of function FirmHarbor::add_hosted_ship -----------//
  875. //--------- Begin of function FirmHarbor::del_hosted_ship ---------//
  876. //
  877. void FirmHarbor::del_hosted_ship(int delUnitRecno)
  878. {
  879. //---- reset the unit_mode of the ship ----//
  880. unit_array[delUnitRecno]->set_mode(0);
  881. //-----------------------------------------//
  882. int i;
  883. for( i=0 ; i<ship_count ; i++ )
  884. {
  885. if( ship_recno_array[i] == delUnitRecno )
  886. {
  887. err_when( ship_count > MAX_SHIP_IN_HARBOR );
  888. m.del_array_rec( ship_recno_array, ship_count, sizeof(ship_recno_array[0]), i+1 );
  889. break;
  890. }
  891. }
  892. err_when( i==ship_count );
  893. ship_count--;
  894. if( firm_recno == firm_array.selected_recno )
  895. put_info(INFO_UPDATE);
  896. }
  897. //----------- End of function FirmHarbor::del_hosted_ship -----------//
  898. //--------- Begin of function FirmHarbor::update_linked_firm_info ---------//
  899. // Note: when ai is finished, ai_link_checked may be used as am indicator
  900. // for link_checked. Performance should be improved in this way.
  901. //
  902. void FirmHarbor::update_linked_firm_info()
  903. {
  904. if(link_checked)
  905. return; // no need to check again
  906. linked_mine_num = linked_factory_num = linked_market_num = 0;
  907. memset(linked_mine_array, 0, sizeof(short)*MAX_LINKED_FIRM_FIRM);
  908. memset(linked_factory_array, 0, sizeof(short)*MAX_LINKED_FIRM_FIRM);
  909. memset(linked_market_array, 0, sizeof(short)*MAX_LINKED_FIRM_FIRM);
  910. Firm *firmPtr;
  911. Nation *nationPtr;
  912. for(int i=linked_firm_count-1; i>=0; i--)
  913. {
  914. if(linked_firm_enable_array[i]!=LINK_EE)
  915. continue;
  916. firmPtr = firm_array[linked_firm_array[i]];
  917. if(!nation_array[nation_recno]->get_relation(firmPtr->nation_recno)->trade_treaty)
  918. continue;
  919. switch(firmPtr->firm_id)
  920. {
  921. case FIRM_MINE:
  922. nationPtr = nation_array[firmPtr->nation_recno];
  923. //if(nationPtr->get_relation_status(nation_recno)<=NATION_TENSE)
  924. // continue;
  925. linked_mine_array[linked_mine_num] = firmPtr->firm_recno;
  926. linked_mine_num++;
  927. break;
  928. case FIRM_FACTORY:
  929. nationPtr = nation_array[firmPtr->nation_recno];
  930. //if(nationPtr->get_relation_status(nation_recno)<=NATION_TENSE)
  931. // continue;
  932. linked_factory_array[linked_factory_num] = firmPtr->firm_recno;
  933. linked_factory_num++;
  934. break;
  935. case FIRM_MARKET:
  936. nationPtr = nation_array[firmPtr->nation_recno];
  937. //if(nationPtr->get_relation_status(nation_recno)<=NATION_TENSE)
  938. // continue;
  939. linked_market_array[linked_market_num] = firmPtr->firm_recno;
  940. linked_market_num++;
  941. break;
  942. }
  943. }
  944. }
  945. //----------- End of function FirmHarbor::update_linked_firm_info -----------//
  946. //--------- Begin of function FirmHarbor::process_queue ---------//
  947. void FirmHarbor::process_queue()
  948. {
  949. if(build_queue_count>0)
  950. {
  951. build_ship(build_queue_array[0], COMMAND_AUTO);
  952. // remove the queue no matter build_ship success or not
  953. m.del_array_rec( build_queue_array, build_queue_count, sizeof(build_queue_array[0]), 1 );
  954. build_queue_count--;
  955. if( firm_array.selected_recno == firm_recno )
  956. {
  957. disable_refresh = 1;
  958. info.disp();
  959. disable_refresh = 0;
  960. }
  961. }
  962. }
  963. //----------- End of function FirmHarbor::process_queue -----------//
  964. //--------- Begin of function FirmHarbor::add_queue ---------//
  965. void FirmHarbor::add_queue(int unitId)
  966. {
  967. if( build_queue_count+(build_unit_id>0)==MAX_BUILD_SHIP_QUEUE )
  968. return;
  969. build_queue_array[build_queue_count++] = unitId;
  970. }
  971. //----------- End of function FirmHarbor::add_queue -----------//
  972. //--------- Begin of function FirmHarbor::remove_queue ---------//
  973. void FirmHarbor::remove_queue(int unitId)
  974. {
  975. for( int i=build_queue_count-1 ; i>=0 ; i-- )
  976. {
  977. if( build_queue_array[i] == unitId )
  978. {
  979. err_when( build_queue_count > MAX_BUILD_SHIP_QUEUE );
  980. m.del_array_rec( build_queue_array, build_queue_count, sizeof(build_queue_array[0]), i+1 );
  981. build_queue_count--;
  982. return;
  983. }
  984. }
  985. if(build_unit_id==unitId)
  986. cancel_build_unit();
  987. }
  988. //----------- End of function FirmHarbor::remove_queue -----------//
  989. //-------- Begin of static function put_ship_rec --------//
  990. //
  991. static void put_ship_rec(int recNo, int x, int y, int refreshFlag)
  992. {
  993. UnitMarine* unitPtr = (UnitMarine*) unit_array[ firm_harbor_ptr->ship_recno_array[recNo-1] ];
  994. UnitInfo* unitInfo = unit_res[unitPtr->unit_id];
  995. //-------- display unit icon -------//
  996. vga_front.d3_panel_down(x+1, y+1, x+UNIT_SMALL_ICON_WIDTH+4, y+UNIT_SMALL_ICON_HEIGHT+4, 2, 0 );
  997. // ###### begin Gilbert 17/10 #######//
  998. vga_front.put_bitmap(x+3, y+3, unit_res[unitPtr->unit_id]->get_small_icon_ptr(unitPtr->rank_id) );
  999. // ###### end Gilbert 17/10 #######//
  1000. y+=6;
  1001. //---------- display unit name ----------//
  1002. font_san.put( x+32 , y, unitInfo->name, 1, x+119 ); // 1-use short words
  1003. //------- display unit hit points -------//
  1004. String str;
  1005. str = (int) unitPtr->hit_points;
  1006. str += "/";
  1007. str += unitPtr->max_hit_points;
  1008. font_san.put( x+125, y, str, 1, x+browse_ship.rec_width-3 );
  1009. }
  1010. //----------- End of static function put_ship_rec -----------//