本文整理汇总了C++中Firm::cast_to_FirmMarket方法的典型用法代码示例。如果您正苦于以下问题:C++ Firm::cast_to_FirmMarket方法的具体用法?C++ Firm::cast_to_FirmMarket怎么用?C++ Firm::cast_to_FirmMarket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Firm
的用法示例。
在下文中一共展示了Firm::cast_to_FirmMarket方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup_link
//------- Begin of function Town::setup_link ---------//
//
void Town::setup_link()
{
//-----------------------------------------------------------------------------//
// check the connected firms location and structure if ai_link_checked is true
//-----------------------------------------------------------------------------//
if(ai_town)
ai_link_checked = 0;
//----- build town-to-firm link relationship -------//
int firmRecno;
Firm* firmPtr;
FirmInfo* firmInfo;
linked_firm_count = 0;
for( firmRecno=firm_array.size() ; firmRecno>0 ; firmRecno-- )
{
if( firm_array.is_deleted(firmRecno) )
continue;
firmPtr = firm_array[firmRecno];
firmInfo = firm_res[firmPtr->firm_id];
if( !firmInfo->is_linkable_to_town )
continue;
//----- only linkable if the firm and the town belong to the same nation or the firm can influence a foreign town, i.e. Camp, Fort and Fryhtan Lair,
if( nation_recno==0 )
{
//--- independent towns can linked to work firms and markets ---//
if( !firmPtr->cast_to_FirmWork() && !firmPtr->cast_to_FirmMarket()
&& !firmPtr->cast_to_FirmCamp() )
{
continue;
}
}
else
{
//--- nation towns can only linked to own firms or camps -------//
if( firmPtr->nation_recno != nation_recno && !firmPtr->cast_to_FirmCamp() )
continue;
}
//---------- check if the firm is close enough to this firm -------//
if( m.points_distance( firmPtr->center_x, firmPtr->center_y, center_x, center_y )
> world.effective_distance(firmPtr->firm_id, 0) )
{
continue;
}
//------ check if both are on the same terrain type ------//
if( (world.get_loc(firmPtr->loc_x1, firmPtr->loc_y1)->is_plateau()==1)
!= (world.get_loc(loc_x1, loc_y1)->is_plateau()==1) )
{
continue;
}
//----- if the firm requires same race -------//
if( !firm_res.is_linkable_to_town(firmPtr->firm_id, firmPtr->race_id, race_id) )
continue;
//------- determine default link flag -------//
int defaultLinkStatus = LINK_EE;
if( nation_recno==0 ) // if this is an independent town
{
if( firmPtr->nation_recno==0 || resistance(firmPtr->nation_recno) > INDEPENDENT_LINK_RESISTANCE )
defaultLinkStatus = LINK_DD;
}
//-------- add the link now -------//
if( linked_firm_count < MAX_LINKED_FIRM_TOWN )
{
err_when( linked_firm_count>0 && linked_firm_array[linked_firm_count-1] == firmRecno ); // BUGHERE - check double linking error
linked_firm_array[linked_firm_count] = firmRecno;
linked_firm_enable_array[linked_firm_count] = defaultLinkStatus;
linked_firm_count++;
}
else
{
err_here();
}
if( firmPtr->linked_town_count < MAX_LINKED_TOWN_TOWN )
{
firmPtr->linked_town_array[firmPtr->linked_town_count] = town_recno;
//.........这里部分代码省略.........
示例2: catch_spy
//-------- Begin of function SpyArray::catch_spy ------//
//
// <int> spyPlace - either SPY_TOWN or SPY_FIRM
// <int> spyPlacePara - town_recno or firm_recno
//
int SpyArray::catch_spy(int spyPlace, int spyPlacePara)
{
int nationRecno, totalPop;
if( spyPlace == SPY_TOWN )
{
Town* townPtr = town_array[spyPlacePara];
nationRecno = townPtr->nation_recno;
totalPop = townPtr->population;
}
else if( spyPlace == SPY_FIRM )
{
Firm* firmPtr = firm_array[spyPlacePara];
nationRecno = firmPtr->nation_recno;
if( firmPtr->cast_to_FirmCamp() )
{
FirmCamp *firmCamp = firmPtr->cast_to_FirmCamp();
totalPop = firmCamp->soldier_count + (firmCamp->overseer_recno>0);
}
else if( firmPtr->cast_to_FirmWork() )
{
FirmWork *firmWork = firmPtr->cast_to_FirmWork();
totalPop = firmWork->worker_count;
}
else if( firmPtr->cast_to_FirmTrain() )
{
totalPop = firmPtr->cast_to_FirmTrain()->trainee_count;
return 0; // don't catch spy
}
else if( firmPtr->cast_to_FirmInn() )
{
totalPop = firmPtr->cast_to_FirmInn()->inn_unit_count;
return 0; // don't catch spy
}
else if( firmPtr->cast_to_FirmMarket() )
{
totalPop = 0;
return 0;
}
else if( firmPtr->cast_to_FirmMonsterTrain() )
{
totalPop = firmPtr->cast_to_FirmMonsterTrain()->trainee_count;
return 0; // don't catch spy
}
else if( firmPtr->cast_to_FirmMonsterAlchemy() )
{
totalPop = 0;
return 0;
}
else if( firmPtr->cast_to_FirmLishorr() )
{
totalPop = 0;
return 0;
}
else if( firmPtr->cast_to_FirmMonsterFortress() )
{
FirmMonsterFortress *firmMonsterFortress = firmPtr->cast_to_FirmMonsterFortress();
totalPop = firmMonsterFortress->archer_count + firmMonsterFortress->extra_builder_count;
}
else if( firmPtr->cast_to_FirmAnimal() )
{
totalPop = 0;
return 0;
}
else if( firmPtr->cast_to_FirmIncubator() )
{
totalPop = 0;
return 0;
}
else if( firmPtr->cast_to_FirmMagic() )
{
totalPop = 0;
return 0;
}
else if( firmPtr->cast_to_FirmOffensive() )
{
totalPop = 0;
return 0;
}
else if( firmPtr->cast_to_FirmOffensive2() )
{
totalPop = 0;
return 0;
}
else
{
err_here();
totalPop = 0;
}
}
else
err_here();
//.........这里部分代码省略.........
示例3: disp_stop
//--------- Begin of function UnitCaravan::disp_stop ---------//
//
void UnitCaravan::disp_stop(int dispY1, int refreshFlag)
{
int y = INFO_Y1 + 94;
int i, j;
for( i = 0; i < MAX_STOP_FOR_CARAVAN; ++i, y += 70 )
{
TradeStop *tradeStop = stop_array+i;
button_go_stop[i].create( INFO_X1+17, y+2, INFO_X1+167, y+35, i_button_go_stop,
ButtonCustomPara( this, tradeStop->firm_recno ) );
button_go_stop[i].set_help_code( "CGOSTOP" );
button_set_stop[i].create( INFO_X1+169, y+2, INFO_X1+215, y+20, i_button_set_stop,
ButtonCustomPara( NULL, 0 ) );
button_set_stop[i].set_help_code( "CSETSTOP" );
button_cancel_stop[i].create( INFO_X1+169, y+21, INFO_X1+215, y+39, i_button_cancel_stop,
ButtonCustomPara( NULL, 0 ) );
button_cancel_stop[i].set_help_code( "CDELSTOP" );
button_reset_stop[i].create( INFO_X1+169, y+42, INFO_X1+215, y+60, i_button_reset_stop,
ButtonCustomPara( NULL, 0 ) );
button_reset_stop[i].set_help_code( "CCLRSEL" );
for( j = 0; j < MAX_GOODS_SELECT_BUTTON; ++j )
button_select_array[i][j].create( INFO_X1+17+carv_gdd_x[j], y+34, INFO_X1+17+carv_gdd_x[j+1]-1, y+61,
i_disp_caravan_select_button, ButtonCustomPara( NULL, j ), 0 );
button_go_stop[i].custom_para = ButtonCustomPara( this, tradeStop->firm_recno );
button_go_stop[i].paint();
button_set_stop[i].paint();
button_cancel_stop[i].paint();
button_reset_stop[i].paint();
Firm *firmPtr = NULL;
if( !firm_array.is_deleted(tradeStop->firm_recno))
firmPtr = firm_array[tradeStop->firm_recno];
for( j = 0; j < MAX_GOODS_SELECT_BUTTON; ++j )
{
// display quantity on the firm
int rawId = j+FIRST_GOODS_SELECT_BUTTON-PICK_UP_RAW_FIRST+1;
if( rawId < 1 || rawId > MAX_RAW )
rawId = 0;
int productId = j+FIRST_GOODS_SELECT_BUTTON-PICK_UP_PRODUCT_FIRST+1;
if( productId < 1 || productId > MAX_PRODUCT )
productId = 0;
int stock = -1;
if( firmPtr )
{
if( firmPtr->cast_to_FirmMarket() )
{
MarketGoods *marketGoods;
if( rawId )
{
marketGoods = firmPtr->cast_to_FirmMarket()->market_raw_array(rawId);
err_when( marketGoods && marketGoods->raw_id != rawId );
}
else if( productId )
{
marketGoods = firmPtr->cast_to_FirmMarket()->market_product_array(productId);
err_when( marketGoods && marketGoods->product_raw_id != productId );
}
else
{
err_here();
marketGoods = NULL;
}
if( marketGoods )
stock = (int) marketGoods->stock_qty;
}
else if( firmPtr->cast_to_FirmMine() )
{
if( rawId && firmPtr->cast_to_FirmMine()->raw_id == rawId )
{
stock = (int) firmPtr->cast_to_FirmMine()->stock_qty;
}
}
else if( firmPtr->cast_to_FirmFactory() )
{
if( productId && firmPtr->cast_to_FirmFactory()->product_raw_id == productId )
{
stock = (int) firmPtr->cast_to_FirmFactory()->stock_qty;
}
//else if( rawId && firmPtr->cast_to_FirmFactory()->product_raw_id == rawId )
//{
// stock = (int) firmPtr->cast_to_FirmFactory()->raw_stock_qty;
//}
}
}
if( stock >= 0 )
//.........这里部分代码省略.........
示例4: draw_dot
//.........这里部分代码省略.........
{
// draw only caravan in trade mode
if( world.map_matrix->map_mode == MAP_MODE_TRADE && unitPtr->unit_id != UNIT_CARAVAN )
continue;
if( filterUnitClassId && unit_res[unitPtr->unit_id]->unit_class != filterUnitClassId )
continue;
// filter selected nation
if( world.map_matrix->filter_nation_flag && world.map_matrix->filter_nation_recno != unitPtr->nation_recno )
continue;
}
//---------------------------------//
if( world.map_matrix->map_mode != MAP_MODE_TRADE )
{
if( unitPtr->cur_action == SPRITE_ATTACK )
nationColor = excitedColorArray[unitPtr->nation_recno];
else if( unitPtr->selected_flag )
nationColor = slowExcitedColorArray[unitPtr->nation_recno];
else
nationColor = nationColorArray[unitPtr->nation_recno];
}
else
{
// if selected firm is mine, factory or market,
// caravan linked to it flashes
err_when( MAX_STOP_FOR_CARAVAN != 2 ); // current code check only two stops
Firm *firmPtr;
if( firm_array.selected_recno
&& (firmPtr = firm_array[firm_array.selected_recno])
&& (firmPtr->cast_to_FirmMine() || firmPtr->cast_to_FirmFactory() || firmPtr->cast_to_FirmMarket())
&& ( ((UnitCaravan *)unitPtr)->stop_array[0].firm_recno == firm_array.selected_recno
|| ((UnitCaravan *)unitPtr)->stop_array[1].firm_recno == firm_array.selected_recno) )
{
nationColor = slowExcitedColorArray[unitPtr->nation_recno];
}
else
{
nationColor = nationColorArray[unitPtr->nation_recno];
}
}
mapX = world.map_matrix->calc_loc_pos_x(unitPtr->cur_x_loc(), unitPtr->cur_y_loc()) + MAP_X1;
mapY = world.map_matrix->calc_loc_pos_y(unitPtr->cur_x_loc(), unitPtr->cur_y_loc()) + MAP_Y1;
dotSize = unitPtr->mobile_type == UNIT_LAND ? 2 : 3;
}
{ // minimize register variable at one time
register short *writePtr = vga_back.buf_ptr(mapX, mapY);
if( dotSize == 2 )
{
if( writePtr[0] != unexploredColor )
writePtr[0] = nationColor;
if( writePtr[1] != unexploredColor )
writePtr[1] = nationColor;
if( writePtr[vgaBufPitch] != unexploredColor )
writePtr[vgaBufPitch] = nationColor;
if( writePtr[vgaBufPitch+1] != unexploredColor )
writePtr[vgaBufPitch+1] = nationColor;