本文整理汇总了C++中Firm类的典型用法代码示例。如果您正苦于以下问题:C++ Firm类的具体用法?C++ Firm怎么用?C++ Firm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Firm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: err_when
//----------- Begin of function Unit::return_camp -----------//
//
// Order this unit to return to the camp. For ordering many
// units to return to a camp, UnitArray::return_camp() should
// be called instead.
//
int Unit::return_camp()
{
if( !home_camp_firm_recno )
return 0;
err_when( firm_array.is_deleted(home_camp_firm_recno) );
Firm* firmPtr = firm_array[home_camp_firm_recno];
if( firmPtr->region_id != region_id() )
return 0;
err_when( !firmPtr->cast_to_FirmCamp() && !firmPtr->cast_to_FirmMonsterFortress() );
err_when( firmPtr->nation_recno != nation_recno );
//--------- assign now ---------//
// ##### begin Gilbert 2/6 #########//
assign(firmPtr->loc_x1, firmPtr->loc_y1, -1, true);
// force_move_flag = 1;
// ##### end Gilbert 2/6 #########//
return cur_action != SPRITE_IDLE;
}
示例2: ai_assign_spy_to_firm
//--------- Begin of function Nation::ai_assign_spy_to_firm --------//
//
// Think about sending spies to the specific firm.
//
// return: <int> 1 - a spy is assigned successfully.
// 0 - failure.
//
int Nation::ai_assign_spy_to_firm(int firmRecno)
{
Firm* firmPtr = firm_array[firmRecno];
err_when( !firmPtr->worker_array );
//---- check if the firm is full or not -----//
if( firmPtr->nation_recno == nation_recno ) // if it's our own firm
{
if( firmPtr->is_worker_full() ) // use is_worker_full() for own firms as it take into account of units patrolling outside
return 0;
}
else
{
if( firmPtr->worker_count == MAX_WORKER )
return 0;
}
//------ look for an existing spy -------//
int raceId = firmPtr->majority_race();
int mobileOnly = firmPtr->nation_recno == nation_recno; // if assign to own firms/firms, only get mobile spies, don't get spies from existing firms/firms as that will result in a loop effect
return ai_assign_spy( firmPtr->loc_x1, firmPtr->loc_y1, raceId, mobileOnly );
}
示例3: release_link
//------- Begin of function Town::release_link ---------//
//
void Town::release_link()
{
int i;
Firm *firmPtr;
Town *townPtr;
//------ release linked firms ------//
for( i=0 ; i<linked_firm_count ; i++ )
{
firmPtr = firm_array[linked_firm_array[i]];
firmPtr->release_town_link(town_recno);
if(firmPtr->is_ai)
firmPtr->ai_link_checked = 0;
if( firmPtr->active_link_town_recno == town_recno )
firmPtr->active_link_town_recno = 0;
}
//------ release linked towns ------//
for( i=0 ; i<linked_town_count ; i++ )
{
townPtr = town_array[linked_town_array[i]];
townPtr->release_town_link(town_recno);
if(townPtr->ai_town)
townPtr->ai_link_checked = 0;
}
}
示例4: toggle_firm_link
//----- Begin of function Town::update_camp_link -----//
//
// Update the status of links from this town to camps.
//
void Town::update_camp_link()
{
//--- enable the link of the town's side to all linked camps ---//
Firm* firmPtr;
int i;
for( i=0 ; i<linked_firm_count ; i++ )
{
firmPtr = firm_array[linked_firm_array[i]];
if( !firmPtr->cast_to_FirmCamp() )
continue;
//--- don't set it if the town and camp both belong to a human player, the player will set it himself ---//
if( firmPtr->nation_recno == nation_recno &&
nation_recno && !nation_array[nation_recno]->is_ai() )
{
continue;
}
//--------------------------------------------//
toggle_firm_link( i+1, 1, COMMAND_AUTO );
}
//------- update camp link status -------//
has_linked_own_camp = 0;
has_linked_enemy_camp = 0;
for( i=0 ; i<linked_firm_count ; i++ )
{
if( linked_firm_enable_array[i] != LINK_EE )
continue;
firmPtr = firm_array[linked_firm_array[i]];
if( !firmPtr->cast_to_FirmCamp() ||
firmPtr->cast_to_FirmCamp()->overseer_recno == 0 )
{
continue;
}
if( firmPtr->nation_recno == nation_recno )
has_linked_own_camp = 1;
else
has_linked_enemy_camp = 1;
}
}
示例5: mobilize_capturer
//-------- Begin of function Nation::mobilize_capturer ------//
//
// Mobilize the capturer unit if he isn't mobilized yet.
//
int Nation::mobilize_capturer(int unitRecno)
{
//--- if the picked unit is an overseer of an existng camp ---//
Unit* unitPtr = unit_array[unitRecno];
if( unitPtr->unit_mode == UNIT_MODE_OVERSEE )
{
Firm* firmPtr = firm_array[unitPtr->unit_mode_para];
Town* townPtr;
//-- can recruit from either a command base or seat of power --//
//-- train a villager with leadership to replace current overseer --//
int i;
for( i=0 ; i<firmPtr->linked_town_count ; i++ )
{
townPtr = town_array[ firmPtr->linked_town_array[i] ];
if( townPtr->nation_recno != nation_recno )
continue;
//--- first try to train a unit who is racially homogenous to the commander ---//
int unitRecno = townPtr->recruit( SKILL_LEADING, firmPtr->majority_race(), COMMAND_AI );
//--- if unsucessful, then try to train a unit whose race is the same as the majority of the town ---//
if( !unitRecno )
unitRecno = townPtr->recruit( SKILL_LEADING, townPtr->majority_race(), COMMAND_AI );
if( unitRecno )
{
add_action(townPtr->loc_x1, townPtr->loc_y1, -1, -1, ACTION_AI_ASSIGN_OVERSEER, FIRM_CAMP);
break;
}
}
if( i==firmPtr->linked_town_count ) // unsuccessful
return 0;
//------- mobilize the current overseer --------//
firmPtr->mobilize_overseer();
}
return 1;
}
示例6: if
//--------- Begin of function SpyArray::update_firm_spy_count ---------//
//
// Update the player_spy_count of this firm. This function is called
// when the firm change its nation.
//
// <int> firmRecno - recno of the firm to be updated.
//
void SpyArray::update_firm_spy_count(int firmRecno)
{
//---- recalculate Firm::player_spy_count -----//
Spy* spyPtr;
Firm* firmPtr = firm_array[firmRecno];
if( firmPtr->cast_to_FirmCamp() )
{
FirmCamp *firmCamp = firmPtr->cast_to_FirmCamp();
firmCamp->player_spy_count = 0;
for( int i=spy_array.size() ; i>0 ; i-- )
{
if( spy_array.is_deleted(i) )
continue;
spyPtr = spy_array[i];
if( spyPtr->spy_place == SPY_FIRM &&
spyPtr->spy_place_para == firmRecno &&
spyPtr->true_nation_recno == nation_array.player_recno )
{
firmCamp->player_spy_count++;
}
}
}
else if( firmPtr->cast_to_FirmTrain() )
{
FirmTrain *firmTrain = firmPtr->cast_to_FirmTrain();
firmTrain->player_spy_count = 0;
for( int i=spy_array.size() ; i>0 ; i-- )
{
if( spy_array.is_deleted(i) )
continue;
spyPtr = spy_array[i];
if( spyPtr->spy_place == SPY_FIRM &&
spyPtr->spy_place_para == firmRecno &&
spyPtr->true_nation_recno == nation_array.player_recno )
{
firmTrain->player_spy_count++;
}
}
}
return;
}
示例7: calc_firm_total
static void calc_firm_total()
{
//-------- calculate firm incomes --------//
total_firm_income = 0;
memset( firm_income_array, 0, sizeof(firm_income_array) );
int thisIncome;
Firm* firmPtr;
int i;
for( i=firm_array.size() ; i>0 ; i-- )
{
if( firm_array.is_deleted(i) )
continue;
firmPtr = firm_array[i];
if( firmPtr->nation_recno == info.viewing_nation_recno )
{
thisIncome = (int) firmPtr->income_365days();
if( thisIncome > 0 )
{
firm_income_array[firmPtr->firm_id-1] += thisIncome;
total_firm_income += thisIncome;
}
}
}
//------ calculate total firm cost --------//
total_firm_count = 0;
total_firm_cost = 0;
FirmInfo* firmInfo;
for( i=1 ; i<=MAX_FIRM_TYPE ; i++ )
{
firmInfo = firm_res[i];
total_firm_cost += firmInfo->year_cost *
firmInfo->nation_firm_count_array[info.viewing_nation_recno-1];
total_firm_count += firmInfo->nation_firm_count_array[info.viewing_nation_recno-1];
}
}
示例8: think_assign_spy_target_camp
//-------- Begin of function Nation::think_assign_spy_target_camp --------//
//
// Think about planting spies into independent towns and enemy towns.
//
int Nation::think_assign_spy_target_camp(int raceId, int regionId)
{
Firm *firmPtr;
int curRating, bestRating=0, bestFirmRecno=0;
for( int firmRecno=firm_array.size() ; firmRecno>0 ; firmRecno-- )
{
if( firm_array.is_deleted(firmRecno) )
continue;
firmPtr = firm_array[firmRecno];
if( firmPtr->nation_recno == nation_recno ) // don't assign to own firm
continue;
if( firmPtr->region_id != regionId )
continue;
if( firmPtr->overseer_recno == 0 ||
firmPtr->worker_count == MAX_WORKER )
{
continue;
}
if( firmPtr->majority_race() != raceId )
continue;
//---------------------------------//
Unit* overseerUnit = unit_array[firmPtr->overseer_recno];
if( overseerUnit->spy_recno ) // if the overseer is already a spy
continue;
curRating = 100 - overseerUnit->loyalty;
if( curRating > bestRating )
{
bestRating = curRating;
bestFirmRecno = firmRecno;
}
}
return bestFirmRecno;
}
示例9: has_linked_camp
//----- Begin of function Town::has_linked_camp -----//
//
// Return whether there is a camp of the specific nation
// linked to this town.
//
// <int> nationRecno - recno of the nation.
// <int> needOverseer - whether only count camps with overseers or not.
//
int Town::has_linked_camp(int nationRecno, int needOverseer)
{
Firm* firmPtr;
for( int i=0 ; i<linked_firm_count ; i++ )
{
firmPtr = firm_array[ linked_firm_array[i] ];
if( firmPtr->cast_to_FirmCamp() &&
firmPtr->nation_recno == nationRecno )
{
if( !needOverseer || firmPtr->cast_to_FirmCamp()->overseer_recno )
return 1;
}
}
return 0;
}
示例10: think_capture_linked_firm
//-------- Begin of function Town::think_capture_linked_firm --------//
//
// Try to capture firms linked to this town if all the workers in firms
// resident in this town.
//
void Town::think_capture_linked_firm()
{
Firm* firmPtr;
//----- scan for linked firms -----//
for( int i=linked_firm_count-1 ; i>=0 ; i-- )
{
firmPtr = firm_array[ linked_firm_array[i] ];
if( firmPtr->nation_recno == nation_recno ) // this is our own firm
continue;
if( firmPtr->can_worker_capture(nation_recno) ) // if we can capture this firm, capture it now
{
firmPtr->capture_firm(nation_recno);
}
}
}
示例11: getDataKey
void Graph::addFirms(int cycleNum, std::vector<Firm*> firms){
for(int i = 0; i < firms.size();i++){
std::string dk = getDataKey("type","firm");
dk += getDataKey("cycleNum",intToStr(cycleNum));
Firm* firm = firms.at(i);
dk+= getDataKey("numIndividuals",intToStr((int)firm->employees.size()));
dk+= getDataKey("avgProductivity",intToStr(firm->getproductivity()));
dk+= getDataKey("unitsLeft",intToStr((int)firm->unitsLeft));
dk+= getDataKey("capital",intToStr(firm->capital));
dk+= getDataKey("firmId",intToStr(firm->id));
addNode(dk,"Cycle-"+intToStr(cycleNum)+"-Firm-"+intToStr(firm->id));
std::string thisCycle = cycles.at(cycles.size()-1).id;
std::string thisFirm = nodes.at(nodes.size()-1).id;
addEdge(thisCycle,thisFirm, str_existsin,(str_existsin+"-"+intToStr(cycleNum)));
addIndividuals(cycleNum,firm,thisFirm);
}
buildTrades(cycleNum,firms);
}
示例12: commander_power
//--------- Begin of function Unit::commander_power ---------//
//
// A commander's power is determined:
//
// -Population of the towns he controls
// -The employment rate of the towns he controls, the higher the
// employment rate, the higher his power is
// -If there are any other commanders controls the towns at the same time.
// -the no. of soldiers led by the commander and their combat levels.
//
int Unit::commander_power()
{
//---- if the commander is in a military camp -----//
int commanderPower=0;
if( unit_mode == UNIT_MODE_OVERSEE )
{
Firm* firmPtr = firm_array[unit_mode_para];
if( firmPtr->cast_to_FirmCamp() )
{
Town* townPtr;
for( int i=firmPtr->linked_town_count-1 ; i>=0 ; i-- )
{
if( firmPtr->linked_town_enable_array[i] == LINK_EE )
{
townPtr = town_array[firmPtr->linked_town_array[i]];
int linkedCampCount = townPtr->linked_camp_count(true);
if( linkedCampCount > 0 )
commanderPower += townPtr->population / linkedCampCount;
}
}
commanderPower += firmPtr->cast_to_FirmCamp()->soldier_count*3; // 0 to 24
}
else if( firmPtr->firm_id == FIRM_BASE )
{
commanderPower = 60;
}
}
else
{
commanderPower = team_info->member_count*3; // 0 to 24
}
return commanderPower;
}
示例13: err_when
void CampaignEastWest::plot_d1_create_game()
{
// reduce cash
(~nation_array)->cash = (~nation_array)->cash / 4;
// reduce mineral if the mine is owned by the player
for( int i = 1; i <= site_array.size(); ++i )
{
if( site_array.is_deleted(i) )
continue;
Site *sitePtr = site_array[i];
if( sitePtr->site_type == SITE_RAW && sitePtr->has_mine )
{
Location *locPtr = world.get_loc(sitePtr->map_x_loc, sitePtr->map_y_loc);
err_when( !locPtr->is_firm() );
Firm *firmPtr = firm_array[locPtr->firm_recno()];
if( firmPtr->is_own() )
{
sitePtr->reserve_qty = sitePtr->reserve_qty / 10;
if( firmPtr->cast_to_FirmMine() )
{
firmPtr->cast_to_FirmMine()->reserve_qty = (float)sitePtr->reserve_qty;
}
else if( firmPtr->cast_to_FirmMonsterAlchemy() )
{
firmPtr->cast_to_FirmMonsterAlchemy()->reserve_qty = (float)sitePtr->reserve_qty;
}
}
}
}
}
示例14: del_firm
//--------- Begin of function FirmArray::del_firm ---------//
//
// Warning : After calling this function, the recno() is still
// pointing to the deleted record.
// So go() to a new record to prevent running NULL object
//
// <int> recNo = the no. of the record to be deleted
// (default : current record no.)
//
void FirmArray::del_firm(int recNo)
{
Firm* firmPtr = firm_array[recNo];
//--- del its link from base_obj_array ----//
base_obj_array.del(firmPtr->base_obj_recno);
//---- delete the object and detach it from firm_array ---//
int xLoc = firmPtr->center_x;
int yLoc = firmPtr->center_y;
if( !sys.quick_exit_flag() )
firmPtr->deinit();
delete firmPtr;
linkout(recNo);
// world.plant_limit = world.plant_limit + m.random(5);
}
示例15: LOG_MSG
//--------- Begin of function FirmArray::next_year ---------//
//
void FirmArray::next_year()
{
int i;
Firm* firmPtr;
LOG_MSG("begin FirmArray::next_year");
LOG_MSG(m.get_random_seed() );
for(i=1; i <=size() ; i++)
{
firmPtr = (Firm*)get_ptr(i);
if( firmPtr && !firmPtr->under_construction )
{
LOG_MSG("Firm next_month");
LOG_MSG( i );
firmPtr->next_year();
LOG_MSG(m.get_random_seed() );
}
}
LOG_MSG("end FirmArray::next_year");
LOG_MSG(m.get_random_seed() );
}