//-------- Begin of function i_disp_build_button --------// // static void i_disp_build_button(ButtonCustom *button, int repaintBody) { int x1 = button->x1; int y1 = button->y1; int x2 = button->x2; int y2 = button->y2; if( !button->pushed_flag ) { if( repaintBody ) { vga_util.blt_buf(x1, y1, x2, y2, 0); vga_util.d3_panel2_up( x1, y1, x2, y2, 1 ); } x2--; y2--; } else { if( repaintBody ) { vga_util.blt_buf(x1, y1, x2, y2, 0); vga_util.d3_panel2_down( x1, y1, x2, y2, 1 ); } x1++; y1++; } ButtonCustom *queueButton = (ButtonCustom *)button->custom_para.ptr; if( repaintBody) { // display unit large icon short unitId = button->custom_para.value; UnitInfo* unitInfo = unit_res[unitId]; vga_front.put_bitmap(x1+6, y1+4, unitInfo->get_large_icon_ptr(0)); err_when( button->custom_para.value != queueButton->custom_para.value); //-------- display unit name --------// String str; str = unitInfo->name; if( unitInfo->unit_class == UNIT_CLASS_WEAPON ) // add version no. { FirmHarbor *harbor = (FirmHarbor *)queueButton->custom_para.ptr; int techLevel = unitInfo->get_nation_tech_level(harbor->nation_recno); if( techLevel > 1 ) { str += " "; str += misc.roman_number(techLevel); } } font_bible.put( x1+60, y1+13, str ); } // display small button queueButton->paint(-1, repaintBody); }
//-------- Begin of function UnitArray::unit_class_size --------// // // Return the size of the class. // int UnitArray::unit_class_size(int unitId) { UnitInfo* unitInfo = unit_res[unitId]; switch(unitId) { case UNIT_CARAVAN: return sizeof(UnitCaravan); // case UNIT_VESSEL: // case UNIT_TRANSPORT: // case UNIT_CARAVEL: // case UNIT_GALLEON: // return sizeof(UnitMarine); case UNIT_WAGON: return sizeof(UnitWagon); break; case UNIT_EXPLOSIVE_CART: return sizeof(UnitExpCart); default: if( unitInfo->is_monster() ) return sizeof(UnitMonster); else if( god_res.is_god_unit(unitId) ) return sizeof(UnitGod); else return sizeof(Unit); } }
//-------- Begin of function i_disp_build_button --------// // static void i_disp_build_button(ButtonCustom *button, int repaintBody) { int x1 = button->x1; int y1 = button->y1; int x2 = button->x2; int y2 = button->y2; short unitId = button->custom_para.value; UnitInfo* unitInfo = unit_res[unitId]; short nationRecno = firm_array[firm_array.selected_recno]->nation_recno; info.draw_unit_icon( x1+34, y1+46, unitId, nationRecno, INFO_X1, INFO_Y1, INFO_X2, INFO_Y2, button->pushed_flag ? 4 : 1 ) ; ButtonCustom *queueButton = (ButtonCustom *)button->custom_para.ptr; err_when( button->custom_para.value != queueButton->custom_para.value); //-------- display unit name --------// String str; str = unitInfo->name; FirmIncubator *incubator = (FirmIncubator *)queueButton->custom_para.ptr; int techLevel = unitInfo->get_nation_tech_level(incubator->nation_recno); if( techLevel > 1 ) // no space for version { str += " "; str += misc.roman_number(techLevel); } // font_whbl.center_put( x1, y1, x1 +67, y1+20, str, 0, 1 ); font_whbl.center_put( x1, y1, x1 +67, y1+20, str, 0, 0 ); font_whbl.center_put( x1-3, y2-22, x1 +67+3, y2-2, misc.format(unit_res[unitId]->build_cost, 2)); // display small button queueButton->paint(-1, repaintBody); }
void FirmIncubator::disp_war_info(int dispY1, int refreshFlag) { static short lastUnitId=0; String str; if( refreshFlag==INFO_UPDATE && lastUnitId != build_unit_id ) { lastUnitId = build_unit_id; info.disp(); } //---------------- paint the panel --------------// if( refreshFlag == INFO_REPAINT ) { button_cancel_build.create(INFO_X1 +182, INFO_Y1 +5, "WRFC_X-U", "WRFC_X-D"); button_cancel_build.set_help_code( "CANCELWP" ); } if( !build_unit_id ) { // str = "No Weapon"; // font_snds.put( INFO_X1+25, INFO_Y1+13, str ); // str = "is under construction !"; // font_snds.put( INFO_X1+25, INFO_Y1+31, str ); font_snds.put_paragraph( INFO_X1+25, INFO_Y1+13, INFO_X1+140, INFO_Y1+46, text_firm.str_no_build_weapon() ); button_cancel_build.enable_flag = 0; } else { //-------- display the icon of the researching item ---------// UnitInfo* unitInfo = unit_res[build_unit_id]; info.draw_unit_icon( INFO_X1 +53, INFO_Y1 +110, build_unit_id, nation_recno, INFO_X1+12, INFO_Y1+55, INFO_X2, INFO_Y2, 1); str = unitInfo->name; int techLevel = unitInfo->get_nation_tech_level(nation_recno); if( techLevel > 1 ) { str += " "; str += misc.roman_number(techLevel); } font_snds.put( INFO_X1+25, INFO_Y1+13, str, 0, -1, 1 ); //-- unitInfo->build_days is the no. of days take to build the firm when productivity is 100, the actually no. of days will be longer if productivity is less than 100 --// float buildProgressDays = build_progress_days; int x = font_snds.put( INFO_X1+25, INFO_Y1+31, (int) buildProgressDays ); x = font_snds.put( x, INFO_Y1+31, " / " ); font_snds.put( x, INFO_Y1+31, (int) unitInfo->build_days ); button_cancel_build.enable_flag = 1; button_cancel_build.paint(); } }
//--------- Begin of function FirmBase::disp_god_info ---------// // void FirmBase::disp_god_info(int dispY1, int refreshFlag) { //---------------- paint the panel --------------// if( refreshFlag == INFO_REPAINT ) vga_util.d3_panel_up( INFO_X1, dispY1, INFO_X2, dispY1+50 ); //-------- display the icon of the mythical creature -------// int x=INFO_X1+4, y=dispY1+4; UnitInfo* unitInfo = unit_res[ god_res[god_id]->unit_id ]; if( refreshFlag == INFO_REPAINT ) { vga_util.d3_panel_down( x, y, x+UNIT_LARGE_ICON_WIDTH+3, y+UNIT_LARGE_ICON_HEIGHT+3, 2 ); vga_front.put_bitmap( x+2, y+2, unitInfo->get_large_icon_ptr(0) ); //----------- display text ------------// x += UNIT_LARGE_ICON_WIDTH+10; font_san.put( x, y+2, unitInfo->name ); } else { x += UNIT_LARGE_ICON_WIDTH+10; } vga_front.indicator( 0x00, x-3, y+18, pray_points, (float) MAX_PRAY_POINTS, 0 ); }
void FirmIncubator::disp_build_menu(int refreshFlag) { int x1 = INFO_X1+13; int y1 = INFO_Y1+5; vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("BLDGWEAP") ); added_count = 0; int unitId, x=INFO_X1+2, y=INFO_Y1; UnitInfo* unitInfo; for( int i = 0; i < MAX_INCUBATE_TYPE; ++i ) { unitId = incubate_unit_id[i]; unitInfo = unit_res[unitId]; if( refreshFlag == INFO_REPAINT ) { button_queue_weapon[added_count].create(x1+20, y1+5, x1+49, y1+34, i_disp_queue_button, ButtonCustomPara(this, unitId) ); button_weapon[added_count].create(x1, y1+35, x1+67, y1+114, i_disp_build_button, ButtonCustomPara(&button_queue_weapon[added_count], unitId) ); } button_weapon[added_count].visible_flag = button_queue_weapon[added_count].visible_flag = unitInfo->get_nation_tech_level(nation_recno) > 0; button_weapon[added_count].paint(); button_queue_weapon[added_count].paint(); added_count++; x1 += 68; if (added_count == 3) { x1 = INFO_X1+13; y1 = INFO_Y1+121; } } if( refreshFlag==INFO_REPAINT ) { // ##### begin Gilbert 8/2 ######// int x1 = INFO_X1 +13 +BUTTON_DISTANCE*3; int y1 = INFO_Y1 +281; // button_cancel.create( x1+7, y1+9, "OK-U", "OK-D" ); button_cancel.create( x1, y1, 'A', "CANCEL" ); // ##### end Gilbert 8/2 ######// } button_cancel.paint(); }
void Unit::init_unit_id(int unitId) { unit_id = unitId; UnitInfo* unitInfo = unit_res[unit_id]; sprite_id = unitInfo->sprite_id; sprite_info = sprite_res[sprite_id]; mobile_type = unitInfo->mobile_type; // #### begin Gilbert 6/11 ######// defense_attribute = unitInfo->defense_attribute; // #### end Gilbert 6/11 ######// //--- if this unit is a weapon unit with multiple versions ---// int techLevel; if( nation_recno && // ##### begin Gilbert 24/3 ########// //unitInfo->unit_class == UNIT_CLASS_WEAPON ) unitInfo->class_info.has_weapon_version ) // ##### end Gilbert 24/3 ########// { techLevel=unitInfo->nation_tech_level_array[nation_recno-1]; if (techLevel == 0) set_weapon_version(1); else set_weapon_version(techLevel); } init_attack_info(); //-------- set unit count ----------// if( nation_recno ) { if( rank_id != RANK_KING ) unitInfo->inc_nation_unit_count(nation_recno); if( rank_id == RANK_GENERAL ) unitInfo->inc_nation_general_count(nation_recno); } //--------- increase monster count ----------// // ##### begin Gilbert 24/3 #######// // if( unit_res[unit_id]->unit_class == UNIT_CLASS_MONSTER ) if( unit_res[unit_id]->class_info.monster_side ) unit_res.mobile_monster_count++; // ##### end Gilbert 24/3 #######// }
void Unit::deinit_unit_id() { if( sys.signal_exit_flag ) return; //-----------------------------------------// UnitInfo *unitInfo = unit_res[unit_id]; if( nation_recno ) { if( rank_id != RANK_KING ) unitInfo->dec_nation_unit_count(nation_recno); if( rank_id == RANK_GENERAL ) unitInfo->dec_nation_general_count(nation_recno); } //--------- if the unit is a spy ----------// // // A spy has double identity and is counted // by both the true controlling nation and // the deceiving nation. // //-----------------------------------------// if( spy_recno && true_nation_recno() != nation_recno ) { err_when( !race_id ); int trueNationRecno = true_nation_recno(); if( rank_id != RANK_KING ) unitInfo->dec_nation_unit_count(trueNationRecno); if( rank_id == RANK_GENERAL ) unitInfo->dec_nation_general_count(trueNationRecno); } //--------- decrease monster count ----------// // ####### begin Gilbert 24/3 #########// // if( unit_res[unit_id]->unit_class == UNIT_CLASS_MONSTER ) if( unit_res[unit_id]->class_info.monster_side ) // ####### end Gilbert 24/3 #########// { unit_res.mobile_monster_count--; err_when( unit_res.mobile_monster_count < 0 ); } }
//-------- Begin of function i_disp_build_button --------// // static void i_disp_build_button(ButtonCustom *button, int repaintBody) { int x1 = button->x1; int y1 = button->y1; int x2 = button->x2; int y2 = button->y2; short unitId = button->custom_para.value; UnitInfo* unitInfo = unit_res[unitId]; short nationRecno = firm_array[firm_array.selected_recno]->nation_recno; info.draw_unit_icon( x1+34, y1+46, unitId, nationRecno, INFO_X1, INFO_Y1, INFO_X2, INFO_Y2, button->pushed_flag ? 4 : 1 ); ButtonCustom *queueButton = (ButtonCustom *)button->custom_para.ptr; err_when( button->custom_para.value != queueButton->custom_para.value); //-------- display unit name --------// String str; str = unitInfo->name; // ##### begin Gilbert 24/3 #########// // if( unitInfo->unit_class == UNIT_CLASS_WEAPON ) // add version no. if( unitInfo->class_info.has_weapon_version ) // add version no. // ##### end Gilbert 24/3 #########// { FirmWar *warFactory = (FirmWar *)queueButton->custom_para.ptr; int techLevel = unitInfo->get_nation_tech_level(warFactory->nation_recno); if( techLevel > 1 ) // no space for version { str += " "; str += misc.roman_number(techLevel); } } // font_whbl.center_put( x1-3, y1, x1 +67+3, y1+20, str, 0, 1 ); font_whbl.center_put( x1-3, y1, x1 +67+3, y1+20, str, 0, 0 ); font_whbl.center_put( x1-3, y2-22, x1 +67+3, y2-2, misc.format(unit_res[unitId]->build_cost, 2)); // display small button queueButton->paint(-1, repaintBody); }
//-------- Begin of function UnitArray::create_unit --------// // Unit* UnitArray::create_unit(int unitId) { Unit* unitPtr; UnitInfo* unitInfo = unit_res[unitId]; switch(unitId) { case UNIT_CARAVAN: unitPtr = new UnitCaravan; break; // case UNIT_VESSEL: // case UNIT_TRANSPORT: // case UNIT_CARAVEL: // case UNIT_GALLEON: // unitPtr = new UnitMarine; // break; case UNIT_WAGON: unitPtr = new UnitWagon; break; case UNIT_EXPLOSIVE_CART: unitPtr = new UnitExpCart; break; default: if( unitInfo->is_monster() ) unitPtr = new UnitMonster; else if( god_res.is_god_unit(unitId) ) unitPtr = new UnitGod; else unitPtr = new Unit; } SpriteArray::add(unitPtr); // it set Sprite::sprite_recno return unitPtr; }
//--------- Begin of function Unit::set_rank ---------// // // Only if the unit has leadership skill, it can be a general or king. // void Unit::set_rank(int rankId) { err_when( !race_id ); if( rank_id == rankId ) return; err_when( unit_mode != UNIT_MODE_REBEL && rankId >= RANK_GENERAL && is_civilian() ); //------- promote --------// if( rankId > rank_id ) change_loyalty(PROMOTE_LOYALTY_INCREASE); //------- demote -----------// else if( rankId < rank_id && rank_id != RANK_KING ) // no decrease in loyalty if a spy king hands his nation to his parent nation and become a general again change_loyalty(-DEMOTE_LOYALTY_DECREASE); //---- update nation_general_count_array[] ----// if( nation_recno ) { UnitInfo* unitInfo = unit_res[unit_id]; if( rank_id == RANK_GENERAL ) // if it was a general originally unitInfo->dec_nation_general_count(nation_recno); if( rankId == RANK_GENERAL ) // if the new rank is general unitInfo->inc_nation_general_count(nation_recno); //------ if demote a king to a unit ------// if( rank_id == RANK_KING && rankId != RANK_KING ) unitInfo->inc_nation_unit_count(nation_recno); // since kings are not included in nation_unit_count, when it is no longer a king, we need to re-increase it. //------ if promote a unit to a king ------// if( rank_id != RANK_KING && rankId == RANK_KING ) unitInfo->dec_nation_unit_count(nation_recno); // since kings are not included in nation_unit_count, we need to decrease it } //----- reset leader_unit_recno if demote a general to soldier ----// if( rank_id == RANK_GENERAL && rankId == RANK_SOLDIER ) { //----- reset leader_unit_recno of the units he commands ----// for( int i=unit_array.size() ; i>0 ; i-- ) { Unit* unitPtr = (Unit*) unit_array.get_ptr(i); // don't use is_deleted() as it filters out units that are currently dying if( unitPtr && unitPtr->leader_unit_recno == sprite_recno ) { unitPtr->leader_unit_recno = 0; // unitPtr->team_id = 0; } } //--------- deinit team_info ---------// err_when( !team_info ); mem_del(team_info); team_info = NULL; // team_id = 0; } //----- if this is a soldier being promoted to a general -----// else if( rank_id == RANK_SOLDIER && rankId == RANK_GENERAL ) { //-- if this soldier is formerly commanded by a general, detech it ---// if( leader_unit_recno ) { if( !unit_array.is_deleted(leader_unit_recno) ) // the leader unit may have been killed at the same time { err_when( !unit_array[leader_unit_recno]->team_info ); unit_array[leader_unit_recno]->team_info->del_member(sprite_recno); } leader_unit_recno = 0; } } // ###### patch begin Gilbert 27/9 #######// // ------- clear royal in campaign mode -----// if( rankId == RANK_KING ) { is_royal = 0; } // ###### patch end Gilbert 27/9 #######// //-------------- update AI info --------------// if( nation_recno ) { if( rank_id == RANK_GENERAL || rank_id == RANK_KING ) nation_array[nation_recno]->del_general_info(sprite_recno); rank_id = rankId; if( rank_id == RANK_GENERAL || rank_id == RANK_KING ) nation_array[nation_recno]->add_general_info(sprite_recno); } else { rank_id = rankId; } //----- if this is a general/king ------// if( rank_id == RANK_GENERAL || rank_id == RANK_KING ) { //--------- init team_info -------// if( !team_info ) { team_info = (TeamInfo*) mem_add( sizeof(TeamInfo) ); memset( team_info, 0, sizeof(TeamInfo) ); } //--- set leadership if this unit does not have any now ----// if( skill_level() < 10 ) skill.set_skill_level( + m.random(40) ); } //------ refresh if the current unit is selected -----// if( unit_array.selected_recno == sprite_recno ) info.disp(); }
void InformationStorage::loadAll(string file) { //Clear out the object types first terrainTypes.clear(); buildingTypes.clear(); unitTypes.clear(); TiXmlDocument doc( file.c_str()); if(doc.LoadFile()) { TiXmlHandle hDoc(&doc); TiXmlElement* pElem; TiXmlHandle hRoot(0); pElem = hDoc.FirstChildElement().Element(); hRoot=TiXmlHandle(pElem); //--------------------------------Load in Units---------------------- TiXmlNode* pUnitNode=hRoot.FirstChild( "Units" ).FirstChild().ToNode(); TiXmlNode* pUnitInfoNode; //For loop will cycle through each unit within the Units tag for( pUnitNode; pUnitNode; pUnitNode=pUnitNode->NextSiblingElement()) { //Need to iterate through the data of a unit; can make a pointer to the first child of pUnitNode for ID, get NextSiblingElement for other elements, use //query attributes for combat stats. UnitInfo u = UnitInfo(); u.load(pUnitNode); unitTypes[u.id] = u; } //----------------------Load in Terrain------------------------------- TiXmlNode* pTerrainNode=hRoot.FirstChild( "Terrain" ).FirstChild().ToNode(); TiXmlNode* pTerrainInfoNode; //For loop will cycle through each unit within the Units tag for( pTerrainNode; pTerrainNode; pTerrainNode=pTerrainNode->NextSiblingElement()) { //Need to iterate through the data of a unit; can make a pointer to the first child of pUnitNode for ID, get NextSiblingElement for other elements, use //query attributes for combat stats. TerrainInfo t = TerrainInfo(); t.load(pTerrainNode); terrainTypes[t.id] = t; } //---------------------------------Load in Buildings-------------------------------------- TiXmlNode* pBuildingNode=hRoot.FirstChild( "Buildings" ).FirstChild().ToNode(); //TiXmlNode* pBuildingInfoNode; //TiXmlNode* pProductionIDNode; //For loop will cycle through each unit within the Units tag for( pBuildingNode; pBuildingNode; pBuildingNode=pBuildingNode->NextSiblingElement()) { //Need to iterate through the data of a unit; can make a pointer to the first child of pUnitNode for ID, get NextSiblingElement for other elements, use //query attributes for combat stats. BuildingInfo b = BuildingInfo(); b.load(pBuildingNode); buildingTypes[b.id] = b; } //-------------------------------Load in Commander Cards-------------------------------- TiXmlNode* pCardNode = hRoot.FirstChild( "Cards" ).FirstChild().ToNode(); for( pCardNode; pCardNode; pCardNode=pCardNode->NextSiblingElement()) { CardInfo c = CardInfo(); c.load(pCardNode); cardTypes[c.id] = c; } } else { //std::cout << "\nFailed to load the units\n"; } DeveloperConsole::write("Buildings Loaded: "); DeveloperConsole::writeLine(buildingTypes.size()); DeveloperConsole::write("Units Loaded: "); DeveloperConsole::writeLine(unitTypes.size()); DeveloperConsole::write("Terrain Loaded: "); DeveloperConsole::writeLine(terrainTypes.size()); }
//--------- Begin of function FirmWar::disp_build_menu ---------// // void FirmWar::disp_build_menu(int refreshFlag) { int x1 = INFO_X1+13; int y1 = INFO_Y1+5; vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("BLDGWEAP") ); if( refreshFlag == INFO_REPAINT ) { added_count=0; } int b = 0; TechClass *techClass = tech_res.tech_class(war_tech_class); // war_tech_class is set the which tech class of weapon to build // int x=INFO_X1+2, y=INFO_Y1; for( int techId = techClass->first_tech_id; techId<techClass->first_tech_id+techClass->tech_count; ++techId ) { short unitId = tech_res[techId]->unit_id; if( !unitId ) continue; UnitInfo* unitInfo = unit_res[unitId]; if( unitInfo->unit_class != UNIT_CLASS_WEAPON ) continue; if( refreshFlag == INFO_REPAINT ) { err_when( b != added_count); button_queue_weapon[added_count].create(x1+20, y1+5, x1+49, y1+34, i_disp_queue_button, ButtonCustomPara(this, unitId) ); button_queue_weapon[added_count].set_help_code( "WEAPNUM" ); button_weapon[added_count].create(x1, y1+35, x1+67, y1+114, i_disp_build_button, ButtonCustomPara(&button_queue_weapon[added_count], unitId) ); added_count++; x1 += 68; if (added_count == 3) { x1 = INFO_X1+13; y1 = INFO_Y1+121; } err_when(added_count > MAX_WEAPON_TYPE); } if( unitInfo->get_nation_tech_level(nation_recno) > 0 ) button_queue_weapon[b].visible_flag = button_weapon[b].visible_flag = 1; else button_queue_weapon[b].visible_flag = button_weapon[b].visible_flag = 0; button_queue_weapon[b].paint(); button_weapon[b].paint(); ++b; } if( refreshFlag==INFO_REPAINT ) { // ##### begin Gilbert 8/2 ######// int x1 = INFO_X1 +13 +BUTTON_DISTANCE*3; int y1 = INFO_Y1 +281; // button_cancel.create( x1+7, y1+9, "OK-U", "OK-D" ); button_cancel.create( x1, y1, 'A', "CANCEL" ); // ##### end Gilbert 8/2 ######// } button_cancel.paint(); }
//--------- Begin of function FirmWar::disp_war_info ---------// // void FirmWar::disp_war_info(int dispY1, int refreshFlag) { static short lastUnitId=0; String str; if( refreshFlag==INFO_UPDATE && lastUnitId != build_unit_id ) { lastUnitId = build_unit_id; info.disp(); } //---------------- paint the panel --------------// // #### begin Gilbert 5/10 ######// if( refreshFlag == INFO_REPAINT ) { button_cancel_build.create(INFO_X1 +182, INFO_Y1 +5, "WRFC_X-U", "WRFC_X-D"); button_cancel_build.set_help_code( "CANCELWP" ); } // #### end Gilbert 5/10 ######// if( !build_unit_id ) { // str = "No Weapon"; // font_snds.put( INFO_X1+25, INFO_Y1+13, str ); // str = "is under construction !"; // font_snds.put( INFO_X1+25, INFO_Y1+31, str ); font_snds.put_paragraph( INFO_X1+25, INFO_Y1+13, INFO_X1+140, INFO_Y1+46, text_firm.str_no_build_weapon() ); // ##### begin Gilbert 5/10 #######// button_cancel_build.enable_flag = 0; // ##### end Gilbert 5/10 #######// } else { //-------- display the icon of the researching item ---------// UnitInfo* unitInfo = unit_res[build_unit_id]; // info.draw_unit_icon( INFO_X1 +53, INFO_Y1 +110, build_unit_id, // nation_recno, INFO_X1+12, INFO_Y1+55, INFO_X2, INFO_Y2, 1); Bitmap *bitmapPtr = (Bitmap *) unitInfo->soldier_icon_ptr; // int x1 = INFO_X1 +53 + unitInfo->unit_icon_offsetx; // int y1 = INFO_Y1 +110 + unitInfo->unit_icon_offsety; // int x2 = x1 + bitmapPtr->get_width() -1; // int y2 = y1 + bitmapPtr->get_height() -1; int x1 = INFO_X1 + 51 - bitmapPtr->get_width()/2; int y1 = INFO_Y1 + 139 - bitmapPtr->get_height(); int x2 = x1 + bitmapPtr->get_width() -1; int y2 = y1 + bitmapPtr->get_height() -1; int srcX1 = MAX(x1, INFO_X1+13)-x1; int srcY1 = 0; int srcX2 = MIN(x2, INFO_X2)-x1; int srcY2 = MIN(y2, INFO_Y2)-y1; short *colorRemapTable = game.get_color_remap_table(nation_recno, 1); vga.active_buf->put_bitmap_area_trans_remap_decompress(x1, y1, (char *) bitmapPtr, srcX1, srcY1, srcX2, srcY2, colorRemapTable); str = unitInfo->name; // ##### begin Gilbert 24/3 #####// // if( unitInfo->unit_class == UNIT_CLASS_WEAPON ) // add version no. if( unitInfo->class_info.has_weapon_version ) // add version no. // ##### end Gilbert 24/3 #####// { int techLevel = unitInfo->get_nation_tech_level(nation_recno); if( techLevel > 1 ) { str += " "; str += misc.roman_number(techLevel); } } font_snds.center_put( INFO_X1+18, INFO_Y1+13, INFO_X2, INFO_Y1+25, str, 0, 1 ); //-- unitInfo->build_days is the no. of days take to build the firm when productivity is 100, the actually no. of days will be longer if productivity is less than 100 --// // ##### begin Gilbert 30/12 #####// float buildProgressDays = build_progress_days; // + (float) (sys.frame_count-last_process_build_frame_no) / FRAMES_PER_DAY // * (float) (worker_count*6+productivity/2) / 100; // ##### end Gilbert 30/12 #####// // str = (int) buildProgressDays; // str += " / "; // str += (int) unitInfo->build_days; // font_snds.put( INFO_X1+25, INFO_Y1+31, str ); int x = font_snds.put( INFO_X1+100, INFO_Y1+31, (int) buildProgressDays ); x = font_snds.put( x, INFO_Y1+31, " / " ); font_snds.put( x, INFO_Y1+31, (int) unitInfo->build_days ); // ##### begin Gilbert 5/10 #######// button_cancel_build.enable_flag = 1; button_cancel_build.paint(); // ##### end Gilbert 5/10 #######// } }
//----- Begin of function FirmWar::think_new_production ------// // // Think about which weapon to produce. // void FirmWar::think_new_production() { //----- first see if we have enough money to build & support the weapon ----// if( !should_build_new_weapon() ) return; //---- calculate the average instance count of all available weapons ---// int weaponTypeCount=0, totalWeaponCount=0; UnitInfo* unitInfo; int unitId; for( unitId=1; unitId<=MAX_UNIT_TYPE ; unitId++ ) { unitInfo = unit_res[unitId]; if( unitInfo->unit_class != UNIT_CLASS_WEAPON || unitInfo->get_nation_tech_level(nation_recno) == 0 ) { continue; } if( unitId == UNIT_EXPLOSIVE_CART ) // AI doesn't use Porcupine continue; weaponTypeCount++; totalWeaponCount += unitInfo->nation_unit_count_array[nation_recno-1]; } if( weaponTypeCount==0 ) // none of weapon technologies is available return; int averageWeaponCount = totalWeaponCount/weaponTypeCount; //----- think about which is best to build now ------// int curRating, bestRating=0, bestUnitId=0; for( unitId=1; unitId<=MAX_UNIT_TYPE ; unitId++ ) { unitInfo = unit_res[unitId]; if( unitInfo->unit_class != UNIT_CLASS_WEAPON ) continue; int techLevel = unitInfo->get_nation_tech_level(nation_recno); if( techLevel==0 ) continue; if( unitId == UNIT_EXPLOSIVE_CART ) //**BUGHERE, don't produce it yet, it needs a different usage than the others. continue; int unitCount = unitInfo->nation_unit_count_array[nation_recno-1]; curRating = averageWeaponCount-unitCount + techLevel*3; if( curRating > bestRating ) { bestRating = curRating; bestUnitId = unitId; } } //------------------------------------// if( bestUnitId ) add_queue( bestUnitId ); }