//--------- Begin of function FirmHarbor::process_build ---------// // void FirmHarbor::process_build() { int totalBuildDays = unit_res[build_unit_id]->build_days; err_when( !build_unit_id ); if( (int)(sys.frame_count-start_build_frame_no) / FRAMES_PER_DAY >= totalBuildDays ) { int unitRecno = unit_array.add_unit( build_unit_id, nation_recno ); add_hosted_ship(unitRecno); if( own_firm() ) se_res.far_sound(center_x, center_y, 1, 'F', firm_id, "FINS", 'S', unit_res[build_unit_id]->sprite_id); build_unit_id = 0; // ##### begin Gilbert 20/9 ########// if( firm_array.selected_recno == firm_recno ) { disable_refresh = 1; info.disp(); disable_refresh = 0; } // ##### end Gilbert 20/9 ########// //-*********** simulate ship movement ************-// //sail_ship(ship_recno_array[0], 0); //-*********** simulate ship movement ************-// } }
//--------- Begin of function Firm::detect_worker_list ---------// // int Firm::detect_worker_list() { if( !should_show_info() ) return 0; //------- detect buttons on hiring firm workers -------// int i, x, y; int liveInTown = firm_res[firm_id]->live_in_town; for( i=0 ; i<worker_count ; i++ ) { x = INFO_X1+6+i%4*50; y = pop_disp_y1+1+i/4*29; switch( mouse.any_click(x, y, x+27, y+23, LEFT_BUTTON) ? 1 : (mouse.any_click(x, y, x+27, y+23, RIGHT_BUTTON) ? 2 : 0) ) { case 1: // left button to select worker selected_worker_id = i+1; return 1; case 2: if( own_firm() ) // only if this is our own firm { //--- if the town where the unit lives belongs to the nation of this firm ---// mobilize_worker(i+1, COMMAND_PLAYER); return 1; } break; } } return 0; }
//--------- Begin of function FirmResearch::detect_main_menu ---------// // void FirmResearch::detect_main_menu() { //-------- detect basic info -----------// if( detect_basic_info() ) return; //----------- detect worker -----------// if( detect_worker_list() ) { disp_research_info(INFO_Y1+54, INFO_UPDATE); disp_worker_info(INFO_Y1+171, INFO_UPDATE); } //-------- detect spy button ----------// detect_spy_button(); if( !own_firm() ) return; //------ detect the select research button -------// if( button_select_research.detect() ) { research_menu_mode = RESEARCH_MENU_RESEARCH; disable_refresh = 1; // static var for disp_info() only info.disp(); disable_refresh = 0; } }
//--------- Begin of function Firm::disp_spy_button --------// // void Firm::disp_spy_button(int x, int y, int refreshFlag) { if( !own_firm() ) // if not own firm, there is not other button other than the spy button, so always display it left-aligned x = INFO_X1; // if own firm, the x passed will be space position on the interface already, taking into account of the other buttons on interface //-------------------------------------// if( player_spy_count > 0 ) { //------------ spy menu -----------// if( refreshFlag == INFO_REPAINT ) button_spy_menu.paint( x, y, 'A', "SPYMENU" ); x += BUTTON_ACTION_WIDTH; //---------- bribe button -----------// if( nation_recno != nation_array.player_recno ) // only display the bribe button for non-player owned towns { int canBribe=0; if( selected_worker_id ) canBribe = can_spy_bribe(selected_worker_id, nation_array.player_recno ); else if( overseer_recno ) canBribe = can_spy_bribe(0, nation_array.player_recno ); //-------- display the bribe button -------// if( refreshFlag == INFO_REPAINT ) button_bribe.paint( x, y, 'A', "SELBRIBE" ); if( canBribe ) button_bribe.enable(); else button_bribe.disable(); x += BUTTON_ACTION_WIDTH; } } //--------- capture button ----------// int canCapture = can_worker_capture(nation_array.player_recno); if( canCapture ) { if( !button_capture.enable_flag || refreshFlag==INFO_REPAINT ) button_capture.paint( x, y, 'A', "CAPTURE" ); } else { if( refreshFlag==INFO_REPAINT ) button_capture.reset(); else if( button_capture.enable_flag ) button_capture.hide(); } }
//--------- Begin of function FirmResearch::process_research --------// // // Process the current research. // void FirmResearch::process_research() { if( !tech_id ) return; //------- make a progress with the research ------// TechInfo* techInfo = tech_res[tech_id]; float progressPoint; if( config.fast_build && nation_recno==nation_array.player_recno ) progressPoint = (float) productivity / 100 + (float) 0.5; else progressPoint = (float) productivity / 300; int newLevel = techInfo->get_nation_tech_level(nation_recno)+1; float levelDivider = ((float)(newLevel+1)/2); // from 1.0 to 2.0 progressPoint = progressPoint * (float) 30 / techInfo->complex_level / levelDivider; // more complex and higher level technology will take longer to research int techId = tech_id; // techInfo->progress() will reset tech_id if the current research level is the max tech level, so we have to save it now if( techInfo->progress(nation_recno, progressPoint) ) { if( tech_id ) // TechRes::progress() may have called terminate_research() if the tech level reaches the maximum { int techId = tech_id; research_complete(); //----- research next level technology automatically -----// if( !firm_ai ) // for player's firm only { if( techInfo->get_nation_tech_level(nation_recno) < techInfo->max_tech_level ) { start_research( techId, COMMAND_AUTO ); if( firm_recno == firm_array.selected_recno ) info.disp(); } } } //--------- add news ---------// if( own_firm() ) { news_array.tech_researched( techId, tech_res[techId]->get_nation_tech_level(nation_recno) ); se_res.far_sound(center_x, center_y, 1, 'F', firm_id, "FINS", 'S', unit_res[tech_res[techId]->unit_id]->sprite_id); } } }
//--------- Begin of function Firm::detect_basic_info ---------// // int Firm::detect_basic_info() { //--- click on the name area to center the map on it ---// if( mouse.single_click(INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+21) ) { world.go_loc( center_x, center_y ); return 1; } //----------- Mobilize the builder ---------// int detectBuilder = builder_recno && !under_construction && unit_array[builder_recno]->is_own(); // this is your unit in your firm or it is a spy of yours in an enemy firm if( detectBuilder && button_builder.detect(0, 0, 1) ) // 1-detect right button also { if( !remote.is_enable() ) set_builder(0); else { // packet structure : <firm recno> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_FIRM_MOBL_BUILDER, sizeof(short)); *shortPtr = firm_recno; } return 1; } //---------------------------------------// if( !own_firm() ) return 0; //---------- "Destruct" button -----------// if( button_destruct.detect(KEY_DEL) ) { if( under_construction ) cancel_construction(COMMAND_PLAYER); else destruct_firm(COMMAND_PLAYER); return 1; } //------------ "Sell" button -------------// if( button_sell.detect(KEY_DEL) ) { sell_firm(COMMAND_PLAYER); return 1; } return 0; }
//--------- Begin of function FirmHarbor::disp_main_menu ---------// // void FirmHarbor::disp_main_menu(int refreshFlag) { firm_harbor_ptr = this; disp_basic_info(INFO_Y1, refreshFlag); if( !should_show_harbor_info() ) return; //-------- display browser -----------// if( refreshFlag == INFO_REPAINT ) { browse_ship.init( SHIP_BROWSE_X1, SHIP_BROWSE_Y1, SHIP_BROWSE_X2, SHIP_BROWSE_Y2, 0, 25, ship_count, put_ship_rec ); browse_ship.open(1); put_det(INFO_REPAINT); } else { if( last_ship_count != ship_count ) { last_ship_count = ship_count; info.disp(); } else browse_ship.update(); // update only } last_ship_count = ship_count; //-------------------------------// if( !own_firm() ) return; //-------- display buttons ---------// if( refreshFlag == INFO_REPAINT ) { button_build.paint( SHIP_DET_X1, SHIP_DET_Y2+4, 'A', "MAKESHIP" ); button_sail.paint ( SHIP_DET_X1+BUTTON_ACTION_WIDTH, SHIP_DET_Y2+4, 'A', "SAILOUT" ); } if( ship_count > 0 ) button_sail.enable(); else button_sail.disable(); //------ display the info of the ship under construction ------// disp_build_info(refreshFlag); }
//--------- Begin of function FirmBase::put_info ---------// // void FirmBase::put_info(int refreshFlag) { disp_basic_info(INFO_Y1, refreshFlag); if( !should_show_info() ) return; disp_base_info(INFO_Y1+54, refreshFlag); disp_worker_list(INFO_Y1+104, refreshFlag); disp_worker_info(INFO_Y1+168, refreshFlag); disp_god_info(INFO_Y1+226, refreshFlag); //------ display button -------// int x, y=INFO_Y1+279; if( own_firm() ) { if( refreshFlag==INFO_REPAINT ) { button_invoke.paint( INFO_X1, y, 'A', "INVOKE" ); button_reward.paint( INFO_X1 + BUTTON_ACTION_WIDTH, y, 'A', "REWARDSP" ); button_vacate_firm.paint(INFO_X1 + BUTTON_ACTION_WIDTH * 2, y, 'A', "RECRUIT"); button_vacate_firm.set_help_code("MOBILIZE"); } if( can_invoke() ) button_invoke.enable(); else button_invoke.disable(); if( nation_array[nation_recno]->cash >= REWARD_COST && ( (overseer_recno && unit_array[overseer_recno]->rank_id != RANK_KING) || selected_worker_id ) ) { button_reward.enable(); } else { button_reward.disable(); } if( have_own_workers() ) button_vacate_firm.enable(); else button_vacate_firm.disable(); x=INFO_X1+BUTTON_ACTION_WIDTH * 3; } else x=INFO_X1; disp_spy_button(x, y, refreshFlag); }
//--------- Begin of function FirmCamp::put_info ---------// // void FirmCamp::put_info(int refreshFlag) { disp_basic_info(INFO_Y1, refreshFlag); if( !should_show_info() ) return; disp_camp_info(INFO_Y1+54, refreshFlag); disp_worker_list(INFO_Y1+104, refreshFlag); disp_worker_info(INFO_Y1+168, refreshFlag); //------ display button -------// int x; if( own_firm() ) { if( refreshFlag==INFO_REPAINT ) { button_patrol.paint( INFO_X1, INFO_Y1+242, 'A', "PATROL" ); button_reward.paint( INFO_X1+BUTTON_ACTION_WIDTH, INFO_Y1+242, 'A', "REWARDCB" ); button_defense.paint( INFO_X2-BUTTON_ACTION_WIDTH, INFO_Y1+242, 'A', defense_flag ? (char*)"DEFENSE1" : (char*)"DEFENSE0" ); } if( overseer_recno || worker_count ) button_patrol.enable(); else button_patrol.disable(); if( nation_array[nation_recno]->cash >= REWARD_COST && ( (overseer_recno && unit_array[overseer_recno]->rank_id != RANK_KING) || selected_worker_id ) ) { button_reward.enable(); } else { button_reward.disable(); } x=INFO_X1+BUTTON_ACTION_WIDTH*2; } else x=INFO_X1; disp_spy_button(x, INFO_Y1+242, refreshFlag); #ifdef DEBUG if( sys.testing_session || sys.debug_session ) disp_debug_info(this, refreshFlag); #endif }
//--------- Begin of function FirmHarbor::detect_main_menu ---------// // void FirmHarbor::detect_main_menu() { firm_harbor_ptr = this; if( detect_basic_info() ) return; if( !own_firm() ) return; if( browse_ship.detect() ) put_det(INFO_UPDATE); if( detect_det() ) return; //------- detect the build button ---------// if( button_build.detect() ) { harbor_menu_mode = HARBOR_MENU_BUILD; disable_refresh = 1; // static var for disp_info() only info.disp(); disable_refresh = 0; } //-------- detect the sail button ---------// if( button_sail.detect() && browse_ship.recno() > 0 ) sail_ship( ship_recno_array[browse_ship.recno()-1], COMMAND_PLAYER ); //---------- detect cancel build button -----------// if(build_unit_id) { if(button_cancel_build.detect()) { if( !remote.is_enable() ) cancel_build_unit(); else { short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_HARBOR_SKIP_SHIP, sizeof(short)); shortPtr[0] = firm_recno; } } } }
//--------- Begin of function FirmInn::detect_info ---------// // void FirmInn::detect_info() { firm_inn_ptr = this; if( detect_basic_info() ) return; //-------- detect spy button ----------// if( !own_firm() ) { detect_spy_button(); return; } //-------------------------------------// if( browse_hire.detect() ) { put_det(INFO_UPDATE); } if( button_hire.detect('R') && inn_unit_count > 0 ) { // ###### begin Gilbert 31/7 #######// se_res.far_sound(center_x, center_y, 1, 'S', unit_res[inn_unit_array[browse_hire.recno()-1].unit_id]->sprite_id, "RDY" ); // ###### end Gilbert 31/7 #######// if(remote.is_enable()) { // packet structure : <firm recno>, <hire Id> <nation no> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_INN_HIRE, 3*sizeof(short)); shortPtr[0] = firm_recno; shortPtr[1] = browse_hire.recno(); shortPtr[2] = nation_recno; } else { hire(browse_hire.recno()); } } }
//--------- Begin of function FirmResearch::disp_main_menu ---------// // void FirmResearch::disp_main_menu(int refreshFlag) { disp_basic_info(INFO_Y1, refreshFlag); if( !should_show_info() ) return; disp_research_info(INFO_Y1+54, refreshFlag); disp_worker_list(INFO_Y1+107, refreshFlag); disp_worker_info(INFO_Y1+171, refreshFlag); if( own_firm() ) { if( refreshFlag==INFO_REPAINT ) button_select_research.paint( INFO_X1, INFO_Y1+235, 'A', "RESEARCH" ); } disp_spy_button( INFO_X1+BUTTON_ACTION_WIDTH, INFO_Y1+235, refreshFlag ); }
//--------- Begin of function FirmFactory::detect_info ---------// // void FirmFactory::detect_info() { //-------- detect basic info -----------// if( detect_basic_info() ) return; //-------- detect workers ----------// if( detect_worker_list() ) // detect this when: it's the player's firm or the player has spies in this firm { disp_worker_list(INFO_Y1+126, INFO_UPDATE); disp_worker_info(INFO_Y1+190, INFO_UPDATE); } //-------- detect spy button ----------// detect_spy_button(); if( !own_firm() ) return; //---- detect change production button -----// if( button_change_production.detect() ) { change_production(); disp_factory_info(INFO_Y1+54, INFO_UPDATE); // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound("TURN_ON"); // ##### end Gilbert 25/9 ######// } //-------- detect mobilize button ----------// if (button_vacate_firm.detect()) { mobilize_all_workers(COMMAND_PLAYER); } }
//--------- Begin of function FirmMine::detect_info ---------// // void FirmMine::detect_info() { //-------- detect basic info -----------// if( detect_basic_info() ) return; //----------- detect worker -----------// if( detect_worker_list() ) { disp_mine_info(INFO_Y1+52, INFO_UPDATE); disp_worker_info(INFO_Y1+191, INFO_UPDATE); } //-------- detect spy button ----------// detect_spy_button(); if( !own_firm() ) return; }
//--------- Begin of function FirmFactory::put_info ---------// // void FirmFactory::put_info(int refreshFlag) { //---------- display info ------------// disp_basic_info(INFO_Y1, refreshFlag); if( !should_show_info() ) return; disp_factory_info(INFO_Y1+54, refreshFlag); disp_worker_list(INFO_Y1+126, refreshFlag); disp_worker_info(INFO_Y1+190, refreshFlag); //------ display mobilize button -------// int x = INFO_X1; if(own_firm()) { if (refreshFlag == INFO_REPAINT) { button_change_production.paint(INFO_X1, INFO_Y1 + 248, 'A', "CHGPROD"); button_vacate_firm.paint(INFO_X1 + BUTTON_ACTION_WIDTH, INFO_Y1 + 248, 'A', "RECRUIT"); button_vacate_firm.set_help_code("MOBILIZE"); } if (worker_count) button_vacate_firm.enable(); else button_vacate_firm.disable(); x += (BUTTON_ACTION_WIDTH * 2); } //---------- display spy button ----------// disp_spy_button(x, INFO_Y1+248, refreshFlag); }
//--------- Begin of function FirmInn::put_det ---------// // void FirmInn::put_det(int refreshFlag) { if( browse_hire.none_record ) { button_hire.reset(); return; } //--------- display details ----------// InnUnit* innUnit = inn_unit_array+browse_hire.recno()-1; disp_unit_info(HIRE_DET_Y1, innUnit, refreshFlag ); //------- paint buttons --------// if( own_firm() ) { if( refreshFlag == INFO_REPAINT ) { button_hire.paint( HIRE_DET_X1, HIRE_DET_Y2+4, 'A', "HIREUNIT" ); } else { if( inn_unit_count > 0 && (~nation_array)->cash >= inn_unit_array[browse_hire.recno()-1].hire_cost ) { button_hire.enable(); } else { button_hire.disable(); } } } }
//------- Begin of function Firm::draw_detect_link_line ---------// // // [int] actionDetect - 0 - this is a draw action // 1 - this is a detect action // (default: 0) // // return: <int> 1 - detected // 0 - not detected // int Firm::draw_detect_link_line(int actionDetect) { if( firm_id == FIRM_INN ) // FirmInn's link is only for scan for neighbor inns quickly, the link line is not displayed return 0; //--------------------------------------// int i, firmX, firmY, townX, townY; Firm* firmPtr; Town* townPtr; FirmInfo* firmInfo = firm_res[firm_id]; //-------- set source points ----------// int srcX = ( ZOOM_X1 + (loc_x1-world.zoom_matrix->top_x_loc) * ZOOM_LOC_WIDTH + ZOOM_X1 + (loc_x2-world.zoom_matrix->top_x_loc+1) * ZOOM_LOC_WIDTH ) / 2; int srcY = ( ZOOM_Y1 + (loc_y1-world.zoom_matrix->top_y_loc) * ZOOM_LOC_HEIGHT + ZOOM_Y1 + (loc_y2-world.zoom_matrix->top_y_loc+1) * ZOOM_LOC_HEIGHT ) / 2; //------ draw lines to linked firms ---------// int lineType; char* bitmapPtr; for( i=0 ; i<linked_firm_count ; i++ ) { firmPtr = firm_array[linked_firm_array[i]]; firmX = ( ZOOM_X1 + (firmPtr->loc_x1-world.zoom_matrix->top_x_loc) * ZOOM_LOC_WIDTH + ZOOM_X1 + (firmPtr->loc_x2-world.zoom_matrix->top_x_loc+1) * ZOOM_LOC_WIDTH ) / 2; firmY = ( ZOOM_Y1 + (firmPtr->loc_y1-world.zoom_matrix->top_y_loc) * ZOOM_LOC_HEIGHT + ZOOM_Y1 + (firmPtr->loc_y2-world.zoom_matrix->top_y_loc+1) * ZOOM_LOC_HEIGHT ) / 2; anim_line.draw_line(&vga_back, srcX, srcY, firmX, firmY, linked_firm_enable_array[i]==LINK_EE ); //----- check if this firm can toggle link or not -----// if( !can_toggle_firm_link(firmPtr->firm_recno) ) continue; //------ if the link is switchable -------// bitmapPtr = power.get_link_icon( linked_firm_enable_array[i], nation_recno==firmPtr->nation_recno ); if( actionDetect ) { if( own_firm() && world.zoom_matrix->detect_bitmap_clip( firmX-11, firmY-11, bitmapPtr ) ) { if( linked_firm_enable_array[i] & LINK_ED ) { toggle_firm_link( i+1, 0, COMMAND_PLAYER ); se_ctrl.immediate_sound("TURN_OFF"); } else { toggle_firm_link( i+1, 1, COMMAND_PLAYER ); se_ctrl.immediate_sound("TURN_ON"); } return 1; } } else { if( nation_recno == nation_array.player_recno ) world.zoom_matrix->put_bitmap_clip( firmX-11, firmY-11, bitmapPtr ); } } //------ draw lines to linked towns ---------// for( i=0 ; i<linked_town_count ; i++ ) { townPtr = town_array[linked_town_array[i]]; townX = ( ZOOM_X1 + (townPtr->loc_x1-world.zoom_matrix->top_x_loc) * ZOOM_LOC_WIDTH + ZOOM_X1 + (townPtr->loc_x2-world.zoom_matrix->top_x_loc+1) * ZOOM_LOC_WIDTH ) / 2; townY = ( ZOOM_Y1 + (townPtr->loc_y1-world.zoom_matrix->top_y_loc) * ZOOM_LOC_HEIGHT + ZOOM_Y1 + (townPtr->loc_y2-world.zoom_matrix->top_y_loc+1) * ZOOM_LOC_HEIGHT ) / 2; if( worker_array && selected_worker_id && worker_array[selected_worker_id-1].town_recno == townPtr->town_recno ) { lineType = -1; anim_line.thick_line(&vga_back, srcX, srcY, townX, townY, linked_town_enable_array[i]==LINK_EE, lineType ); } else { lineType = 0; anim_line.draw_line(&vga_back, srcX, srcY, townX, townY, linked_town_enable_array[i]==LINK_EE, lineType ); } //----- check if this firm can toggle link or not -----// if( !can_toggle_town_link() ) continue; //--------- draw link symbol -----------// bitmapPtr = power.get_link_icon( linked_town_enable_array[i], nation_recno==townPtr->nation_recno ); if( actionDetect ) { int rc = world.zoom_matrix->detect_bitmap_clip( townX-11, townY-11, bitmapPtr ); //------ left clicking to toggle link -------// if( rc==1 && own_firm() ) { if( linked_town_enable_array[i] & LINK_ED ) { toggle_town_link( i+1, 0, COMMAND_PLAYER ); se_ctrl.immediate_sound("TURN_OFF"); } else { toggle_town_link( i+1, 1, COMMAND_PLAYER ); se_ctrl.immediate_sound("TURN_ON"); } // // update RemoteMsg::firm_toggle_link_town() // if( firm_id == FIRM_CAMP && !remote.is_enable()) { if( townPtr->nation_recno ) townPtr->update_target_loyalty(); else townPtr->update_target_resistance(); townPtr->update_camp_link(); } return 1; } //------ right clicking to move workers ------// else if( rc==2 && selected_worker_id > 0 ) { //--- only when this worker is ours ----// if( firm_res[firm_id]->live_in_town && worker_array[selected_worker_id-1].is_nation(firm_recno, nation_array.player_recno) ) { if(townPtr->population>=MAX_TOWN_POPULATION) return 0; set_worker_home_town(townPtr->town_recno, COMMAND_PLAYER); se_ctrl.immediate_sound("PULL_MAN"); return 1; } } } else { if( nation_recno == nation_array.player_recno ) world.zoom_matrix->put_bitmap_clip( townX-11, townY-11, bitmapPtr ); } } return 0; }
//--------- Begin of function FirmCamp::detect_info ---------// // void FirmCamp::detect_info() { if( detect_basic_info() ) return; if( !should_show_info() ) return; //------ detect the overseer button -----// int rc = mouse.single_click(INFO_X1+6, INFO_Y1+58, INFO_X1+5+UNIT_LARGE_ICON_WIDTH, INFO_Y1+57+UNIT_LARGE_ICON_HEIGHT, 2 ); if( rc==1 ) // display this overseer's info { selected_worker_id = 0; disp_camp_info(INFO_Y1+54, INFO_UPDATE); disp_worker_list(INFO_Y1+104, INFO_UPDATE); disp_worker_info(INFO_Y1+168, INFO_UPDATE); } //--------- detect soldier info ---------// if( detect_worker_list() ) { disp_camp_info(INFO_Y1+54, INFO_UPDATE); disp_worker_list(INFO_Y1+104, INFO_UPDATE); disp_worker_info(INFO_Y1+168, INFO_UPDATE); } //---------- detect spy button ----------// detect_spy_button(); if( !own_firm() ) return; //------ detect the overseer button -----// if( rc==2 ) { if(remote.is_enable()) { // packet structure : <firm recno> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_FIRM_MOBL_OVERSEER, sizeof(short)); shortPtr[0] = firm_recno; } else { assign_overseer(0); // the overseer quits the camp } } //----------- detect patrol -----------// if( button_patrol.detect() ) { if(remote.is_enable()) { // packet structure : <firm recno> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_CAMP_PATROL, sizeof(short)); shortPtr[0] = firm_recno; } else { patrol(); } } //----------- detect reward -----------// if( button_reward.detect() ) { reward(selected_worker_id, COMMAND_PLAYER); // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound("TURN_ON"); // ##### end Gilbert 25/9 ######// } //----- detect defense mode button -------// if( button_defense.detect() ) { // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound( !defense_flag?(char*)"TURN_ON":(char*)"TURN_OFF"); // ##### end Gilbert 25/9 ######// if( !remote.is_enable() ) { // update RemoteMsg::toggle_camp_patrol() defense_flag = !defense_flag; } else { // packet structure : <firm recno> <defense_flag> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_CAMP_TOGGLE_PATROL, 2*sizeof(short)); shortPtr[0] = firm_recno; shortPtr[1] = !defense_flag; } button_defense.update_bitmap( defense_flag ? (char*)"DEFENSE1" : (char*)"DEFENSE0" ); } }
//--------- Begin of function FirmBase::detect_info ---------// // void FirmBase::detect_info() { if( detect_basic_info() ) return; if( !should_show_info() ) return; //------ detect the overseer button -----// int rc = mouse.any_click(INFO_X1+6, INFO_Y1+58, INFO_X1+5+UNIT_LARGE_ICON_WIDTH, INFO_Y1+57+UNIT_LARGE_ICON_HEIGHT, LEFT_BUTTON) ? 1 : mouse.any_click(INFO_X1+6, INFO_Y1+58, INFO_X1+5+UNIT_LARGE_ICON_WIDTH, INFO_Y1+57+UNIT_LARGE_ICON_HEIGHT, RIGHT_BUTTON) ? 2 : 0; if( rc==1 ) // display this overseer's info { selected_worker_id = 0; disp_base_info(INFO_Y1+54, INFO_UPDATE); disp_worker_list(INFO_Y1+104, INFO_UPDATE); disp_worker_info(INFO_Y1+168, INFO_UPDATE); } //--------- detect soldier info ---------// if( detect_worker_list() ) { disp_base_info(INFO_Y1+54, INFO_UPDATE); disp_worker_list(INFO_Y1+104, INFO_UPDATE); disp_worker_info(INFO_Y1+168, INFO_UPDATE); } //---------- detect spy button ----------// detect_spy_button(); if( !own_firm() ) return; //------ detect the overseer button -----// if( rc==2 ) { if(remote.is_enable()) { // packet structure : <firm recno> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_FIRM_MOBL_OVERSEER, sizeof(short)); shortPtr[0] = firm_recno; } else { assign_overseer(0); // the overseer quits the camp } } //----------- detect invoke -----------// if( button_invoke.detect() ) { if(remote.is_enable()) { // ##### begin Gilbert 14/10 #######// // packet structure : <firm recno> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_BASE_INVOKE_GOD, sizeof(short)); shortPtr[0] = firm_recno; // ##### end Gilbert 14/10 #######// } else { invoke_god(); } } //----------- detect reward -----------// if( button_reward.detect() ) { reward(selected_worker_id, COMMAND_PLAYER); // ##### begin Gilbert 26/9 ########// se_ctrl.immediate_sound("TURN_ON"); // ##### end Gilbert 26/9 ########// } }