//--------- Begin of function FirmArray::process ---------// // // Process all firm in firm_array for action and movement for next frame // // Return : 1 - all firm in the FirmArray has been processed // 0 - only some has been processed, not all // int FirmArray::process() { int i; Firm *firmPtr; // ####### begin Gilbert 19/11 ######// if( sys.day_frame_count == 0 ) { god_res.update_prayer_count(); // count no. of prayer of each god, each nation } // ####### end Gilbert 19/11 ######// //----- each time process some firm only ------// for( i=1 ; i<=size() ; i++ ) { firmPtr = (Firm*) get_ptr(i); if( !firmPtr ) // the firm has been deleted continue; err_when(firmPtr->firm_recno!=i); //-------- system yield ---------// if( i%20==1 ) sys.yield(); #if defined(ENABLE_LOG) String logStr; logStr = "begin process firm "; logStr += firmPtr->firm_recno; logStr += " nation="; logStr += firmPtr->nation_recno; LOG_MSG(logStr); #endif if(i==50) { FirmMarket *mPtr = (FirmMarket*) firmPtr; MarketGoods *marketGoods = mPtr->market_goods_array; marketGoods++; if(marketGoods->stock_qty) int debug = 0; } // ##### begin Gilbert 18/5 ########// //-------- process visibility -----------// if( i%FRAMES_PER_DAY == int(sys.frame_count%FRAMES_PER_DAY) ) // only process each firm once per day { // before under construction checking if( firmPtr->explore_for_player() ) { world.visit( firmPtr->loc_x1, firmPtr->loc_y1, firmPtr->loc_x2, firmPtr->loc_y2, EXPLORE_RANGE-1 ); } } // ##### begin Gilbert 18/5 ########// //------ if the firm is under construction ------// if( firmPtr->under_construction ) { LOG_MSG(" process_construction"); firmPtr->process_construction(); LOG_MSG(m.get_random_seed() ); continue; } //------ if the firm is being upgrade ------// if( firmPtr->upgrading_firm_id ) { if( firmPtr->process_upgrade() ) continue; } // ###### begin Gilbert 4/1 #######// firmPtr->process(); // ###### end Gilbert 4/1 #######// //--------- process and process_ai firms ----------// if( i%FRAMES_PER_DAY == int(sys.frame_count%FRAMES_PER_DAY) ) // only process each firm once per day { #ifdef DEBUG unsigned long profileStartTime = m.get_time(); #endif // //-------- process visibility -----------// // // if( firmPtr->explore_for_player() ) // { // world.visit( firmPtr->loc_x1, firmPtr->loc_y1, firmPtr->loc_x2, firmPtr->loc_y2, EXPLORE_RANGE-1 ); // } LOG_MSG(" next_day"); firmPtr->next_day(); LOG_MSG(m.get_random_seed() ); #ifdef DEBUG firm_profile_time += m.get_time() - profileStartTime; #endif //-- if the hit points drop to zero, the firm should be deleted --// if( firmPtr->hit_points <=0 ) { se_res.sound( firmPtr->center_x, firmPtr->center_y, 1, 'F', firmPtr->firm_id, "DEST" ); del_firm( firmPtr->firm_recno ); continue; } //--------- process AI ------------// #ifdef DEBUG if( config.disable_ai_flag==0 && firmPtr->is_ai ) #else if( firmPtr->is_ai ) #endif { LOG_MSG(" process_common_ai"); firmPtr->process_common_ai(); LOG_MSG(m.get_random_seed() ); #ifdef DEBUG unsigned long profileAiStartTime = m.get_time(); #endif LOG_MSG(" process_ai"); firmPtr->process_ai(); LOG_MSG(m.get_random_seed()); #ifdef DEBUG firm_ai_profile_time += m.get_time() - profileAiStartTime; #endif if( is_deleted(i) ) // the firm may have been deleted in process_ai() continue; } } //-------- process animation ---------// LOG_MSG(" process_animation"); firmPtr->process_animation(); LOG_MSG( m.get_random_seed() ); //-------- process monster firm ---------// LOG_MSG(" process_animation"); firmPtr->process_monster_firm(); LOG_MSG( m.get_random_seed() ); } return 0; }