当前位置: 首页>>代码示例>>C++>>正文


C++ Nation::add_action方法代码示例

本文整理汇总了C++中Nation::add_action方法的典型用法代码示例。如果您正苦于以下问题:C++ Nation::add_action方法的具体用法?C++ Nation::add_action怎么用?C++ Nation::add_action使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nation的用法示例。


在下文中一共展示了Nation::add_action方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ai_build_camp

//--------- Begin of function Unit::ai_build_camp --------//
//
// Order this unit to build a camp in its region.
//
int Unit::ai_build_camp()
{
	//--- to prevent building more than one camp at the same time ---//

	int     curRegionId = region_id();
	Nation* ownNation = nation_array[nation_recno];

	if( ownNation->is_action_exist( ACTION_AI_BUILD_FIRM, FIRM_CAMP, curRegionId ) )
		return 0;

	//------- locate a place for the camp --------//

	FirmInfo* firmInfo = firm_res[FIRM_CAMP];
	int 		 xLoc=0, yLoc=0;
	char 	 	 teraMask = UnitRes::mobile_type_to_mask(UNIT_LAND);

	if( world.locate_space_random(xLoc, yLoc, MAX_WORLD_X_LOC-1,
		 MAX_WORLD_Y_LOC-1, firmInfo->loc_width+2, firmInfo->loc_height+2,   // leave at least one location space around the building
		 MAX_WORLD_X_LOC*MAX_WORLD_Y_LOC, curRegionId, 1, teraMask) )
	{
		return ownNation->add_action( xLoc, yLoc, -1, -1,
					ACTION_AI_BUILD_FIRM, FIRM_CAMP, 1, sprite_recno );
	}

	return 0;
}
开发者ID:MicroVirus,项目名称:7kaa,代码行数:30,代码来源:OUNITAI.cpp

示例2: ai_recruit_worker

//------- Begin of function Firm::ai_recruit_worker -----------//
//
int Firm::ai_recruit_worker()
{
	if( worker_count == MAX_WORKER )
		return 0;

	Nation* nationPtr = nation_array[nation_recno];
	Town*   townPtr;

	for( int i=0; i<linked_town_count ; i++ )
	{
		if( linked_town_enable_array[i] != LINK_EE )
			continue;

		townPtr = town_array[ linked_town_array[i] ];

		//-- only recruit workers from towns of other nations if we don't have labor ourselves

		if( townPtr->nation_recno != nation_recno &&
			 nationPtr->total_jobless_population > MAX_WORKER )
		{
			continue;
		}

		if( townPtr->jobless_population > 0 )
			return 0;		// don't order units to move into it as they will be recruited from the town automatically
	}

	//---- order workers to move into the firm ----//

	nationPtr->add_action(loc_x1, loc_y1, -1, -1, ACTION_AI_ASSIGN_WORKER, firm_id, MAX_WORKER-worker_count);

	return 1;
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:35,代码来源:OFIRMAI.cpp

示例3: think_spying_town_assign_to

//-------- Begin of function Town::think_spying_town_assign_to --------//
//
// Think about planting spies into independent towns and enemy towns.
//
int Town::think_spying_town_assign_to(int raceId)
{
	Nation* ownNation = nation_array[nation_recno];

	int targetTownRecno = ownNation->think_assign_spy_target_town(race_id, region_id);

	if( !targetTownRecno )
		return 0;

	//------- assign the spy now -------//

	int unitRecno = recruit(SKILL_SPYING, raceId, COMMAND_AI);

	if( !unitRecno )
		return 0;

	Town* targetTown = town_array[targetTownRecno];

	int actionRecno = ownNation->add_action( targetTown->loc_x1, targetTown->loc_y1,
							-1, -1, ACTION_AI_ASSIGN_SPY, targetTown->nation_recno, 1, unitRecno );

	if( !actionRecno )
		return 0;

	train_unit_action_id = ownNation->get_action(actionRecno)->action_id;

	return 1;
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:32,代码来源:OTOWNAI.cpp

示例4: think_build_export_market

//------- Begin of function FirmMarket::think_build_export_market -----------//
//
// Think about export goods of this market to other markets.
//
int FirmMarket::think_build_export_market(int townRecno)
{
	Town* 		townPtr = town_array[townRecno];
	Firm* 		firmPtr;
	Nation* 		nationPtr = nation_array[nation_recno];

	//---- see if we already have a market linked to this town ----//

	for( int i=0 ; i<townPtr->linked_firm_count ; i++ )
	{
		firmPtr = firm_array[ townPtr->linked_firm_array[i] ];

		if( firmPtr->firm_id != FIRM_MARKET || firmPtr->firm_recno==firm_recno )
			continue;

		//--- if we already have a market there, no need to build a new market ----//

		if( firmPtr->nation_recno == nation_recno )
			return 0;
	}

	//--- if there is no market place linked to this town, we can set up one ourselves ---//

	short buildXLoc, buildYLoc;

	if( !nationPtr->find_best_firm_loc(FIRM_MARKET, townPtr->loc_x1, townPtr->loc_y1, buildXLoc, buildYLoc) )
	{
		townPtr->no_neighbor_space = 1;
		return 0;
	}

	nationPtr->add_action(buildXLoc, buildYLoc, townPtr->loc_x1, townPtr->loc_y1, ACTION_AI_BUILD_FIRM, FIRM_MARKET);
	return 1;
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:38,代码来源:OF_MARK2.cpp

示例5: think_build_market

//------- Begin of function FirmMine::think_build_market -----------//
//
int FirmMine::think_build_market()
{
	if( no_neighbor_space )		// if there is no space in the neighbor area for building a new firm.
		return 0;

	Nation* nationPtr = nation_array[nation_recno];

	//-- only build a new market when the mine has a larger supply than the demands from factories and market places

	if( stock_qty < max_stock_qty * 0.2 )
		return 0;

	//--- check whether the AI can build a new firm next this firm ---//

	if( !nationPtr->can_ai_build(FIRM_MARKET) )
		return 0;

	//-- only build one market place next to this mine, check if there is any existing one --//

	FirmMarket* firmPtr;

	for(int i=0; i<linked_firm_count; i++)
	{
		err_when(!linked_firm_array[i] || firm_array.is_deleted(linked_firm_array[i]));

		firmPtr = (FirmMarket*) firm_array[linked_firm_array[i]];

		if(firmPtr->firm_id!=FIRM_MARKET)
			continue;

		//------ if this market is our own one ------//

		if( firmPtr->nation_recno == nation_recno &&
			 ((FirmMarket*)firmPtr)->is_retail_market==0 )  // if it already has a raw material market, then no need to build a new one
		{
			return 0;
		}
	}

	//------ queue building a new market -------//

	short buildXLoc, buildYLoc;

	if( !nationPtr->find_best_firm_loc(FIRM_MARKET, loc_x1, loc_y1, buildXLoc, buildYLoc) )
	{
		no_neighbor_space = 1;
		return 0;
	}

	nationPtr->add_action(buildXLoc, buildYLoc, loc_x1, loc_y1, ACTION_AI_BUILD_FIRM, FIRM_MARKET);

	return 1;
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:55,代码来源:OF_MINE2.cpp

示例6: ai_build_neighbor_firm

//------- Begin of function Firm::ai_build_neighbor_firm -----------//
//
int Firm::ai_build_neighbor_firm(int firmId)
{
	short   buildXLoc, buildYLoc;
	Nation* nationPtr = nation_array[nation_recno];

	if( !nationPtr->find_best_firm_loc(firmId, loc_x1, loc_y1, buildXLoc, buildYLoc) )
	{
		no_neighbor_space = 1;
		return 0;
	}

	nationPtr->add_action(buildXLoc, buildYLoc, loc_x1, loc_y1, ACTION_AI_BUILD_FIRM, firmId);
	return 1;
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:16,代码来源:OFIRMAI.cpp

示例7: ai_build_firm

//--------- Begin of function Unit::ai_build_firm --------//
//
// Order this unit to build a camp in its region.
//
int Unit::ai_build_firm()
{
	//--- don't build if the race of the nation and the unit is different ----//

	if( nation_array[nation_recno]->is_human() != is_human() )
		return 0;

	//---------------------------------------------------------------//

	int firmId;

	if( is_human() )
		firmId = FIRM_FORT;
	else
		firmId = FIRM_LAIR;

	if( !firm_res[firmId]->can_build(sprite_recno) )
		return 0;

	//--- to prevent building more than one camp at the same time ---//

	int     curRegionId = region_id();
	Nation* ownNation = nation_array[nation_recno];

	if( ownNation->is_action_exist( ACTION_AI_BUILD_FIRM, firmId, curRegionId ) )
		return 0;

	//------- locate a place for the camp --------//

	FirmInfo* firmInfo = firm_res[firmId];
	char 	 	 teraMask = UnitRes::mobile_type_to_mask(UNIT_LAND);
	int 		 xLoc=next_x_loc(), yLoc=next_y_loc();

	if( world.locate_space(xLoc, yLoc, xLoc, yLoc,
		 firmInfo->loc_width+INTER_PLACE_SPACE*2,
		 firmInfo->loc_height+INTER_PLACE_SPACE*2,   // leave at least one location space around the building
		 UNIT_LAND, curRegionId, 1) )
	{
		return ownNation->add_action( xLoc, yLoc, -1, -1,
					ACTION_AI_BUILD_FIRM, firmId, 1, sprite_recno );
	}

	return 0;
}
开发者ID:112212,项目名称:7k2,代码行数:48,代码来源:oun_ai.cpp

示例8: send_talk_msg_now

//------- Begin of function TalkRes::send_talk_msg_now --------//
//
void TalkRes::send_talk_msg_now(TalkMsg* talkMsgPtr)
{
	//--------- add the message ------------//

	Nation* toNation = nation_array[talkMsgPtr->to_nation_recno];

	talkMsgPtr->date = info.game_date;
	talkMsgPtr->relation_status = toNation->get_relation_status(talkMsgPtr->from_nation_recno);

	talk_msg_array.linkin( talkMsgPtr );

	err_when( nation_array.is_deleted(talkMsgPtr->from_nation_recno) );
	err_when( nation_array.is_deleted(talkMsgPtr->to_nation_recno) );

	//--------------------------------------//

	switch(toNation->nation_type)
	{
		case NATION_OWN:		// can be from both AI or a remote player
			if( news_array.diplomacy( talk_msg_array.recno() ) )
				se_ctrl.immediate_sound(talkMsgPtr->talk_id==TALK_DECLARE_WAR ? (char*)"DECL_WAR":(char*)"GONG");
			break;

		case NATION_AI:
			if( talkMsgPtr->reply_type == REPLY_WAITING )
			{
				//-- put the message in the receiver's actin queue --//

				toNation->add_action( 0, 0, 0, 0, ACTION_AI_PROCESS_TALK_MSG, talk_msg_array.recno() );
			}
			else if( talkMsgPtr->reply_type == REPLY_NOT_NEEDED )
			{
				//--- notify the receiver immediately ---//

				toNation->notify_talk_msg( talkMsgPtr );
			}
			else
				err_here();
			break;

		case NATION_REMOTE:	// do nothing here as NATION_OWN handle both msg from AI and a remote player
			break;
	}
}
开发者ID:mecirt,项目名称:7k2,代码行数:46,代码来源:otalkres.cpp

示例9: think_scout

//-------- Begin of function Town::think_scout --------//
//
int Town::think_scout()
{
	Nation* ownNation = nation_array[nation_recno];

	if( config.explore_whole_map )
		return 0;

	if( info.game_date > info.game_start_date + 50 + ownNation->pref_scout )	// only in the first half year of the game
		return 0;

	if( ownNation->ai_town_count > 1 ) 													// only when there is only one town
		return 0;

	//-------------------------------------------//

	int destX, destY;

	if( m.random(2)==0 )
		destX = center_x + 50 + m.random(50);
	else
		destX = center_x - 50 - m.random(50);

	if( m.random(2)==0 )
		destY = center_y + 50 + m.random(50);
	else
		destY = center_y - 50 - m.random(50);

	destX = max(0, destX);
	destX = min(MAX_WORLD_X_LOC-1, destX);

	destY = max(0, destY);
	destY = min(MAX_WORLD_Y_LOC-1, destY);

	ownNation->add_action( destX, destY, loc_x1, loc_y1, ACTION_AI_SCOUT, 0);

	return 1;
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:39,代码来源:OTOWNAI.cpp

示例10: think_repair

//------- Begin of function Firm::think_repair -----------//
//
void Firm::think_repair()
{
	Nation* ownNation = nation_array[nation_recno];

	//----- check if the damage is serious enough -----//

	if( hit_points >=
		 max_hit_points * (70+ownNation->pref_repair_concern/4) / 100 )	// 70% to 95%
	{
		return;
	}

	//--- if it's no too heavily damaged, it is just that the AI has a high concern on this ---//

	if( hit_points >= max_hit_points * 80 / 100 )
	{
		if( ownNation->total_jobless_population < 15 )
			return;
	}

	//------- queue assigning a construction worker now ------//

	ownNation->add_action(loc_x1, loc_y1, -1, -1, ACTION_AI_ASSIGN_CONSTRUCTION_WORKER, firm_id);
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:26,代码来源:OFIRMAI.cpp

示例11: think_leader_action

//--------- Begin of function Unit::think_leader_action --------//
//
// Think about the action of a leader (either a general or a king).
//
int Unit::think_leader_action()
{
	Nation*   nationPtr = nation_array[nation_recno];
	FirmCamp *firmCamp, *bestCamp=NULL;
	int		 curRating, bestRating=10, delActionRecno=0;
	int		 curXLoc = next_x_loc(), curYLoc = next_y_loc();
	int		 curRegionId = world.get_region_id( curXLoc, curYLoc );

	if( rank_id == RANK_KING )		// if this unit is the king, always assign it to a camp regardless of whether the king is a better commander than the existing one
		bestRating = -1000;

	err_when( skill.skill_id != SKILL_LEADING );

	//----- think about which camp to move to -----//

	for( int i=nationPtr->ai_camp_count-1 ; i>=0 ; i-- )
	{
		firmCamp = (FirmCamp*) firm_array[ nationPtr->ai_camp_array[i] ];

		if( firmCamp->region_id != curRegionId )
			continue;

		//--- if the commander of this camp is the king, never replace him ---//

		if( firmCamp->overseer_recno == nationPtr->king_unit_recno )
			continue;

		//-------------------------------------//

		int curLeadership = firmCamp->cur_commander_leadership();
		int newLeadership = firmCamp->new_commander_leadership(race_id, skill.skill_level);

		curRating = newLeadership - curLeadership;

		//-------------------------------------//

		if( curRating > bestRating )
		{
			//--- if there is already somebody being assigned to it ---//

			int actionRecno=0;

			if( rank_id != RANK_KING )			// don't check this if the current unit is the king
			{
				actionRecno = nationPtr->is_action_exist(firmCamp->loc_x1, firmCamp->loc_y1,
								  -1, -1, ACTION_AI_ASSIGN_OVERSEER, FIRM_CAMP);

				if( actionRecno && nationPtr->get_action(actionRecno)->processing_instance_count )
					continue;
			}

			bestRating = curRating;
			bestCamp   = firmCamp;
			delActionRecno = actionRecno;
		}
	}

	if( !bestCamp )
		return 0;

	//----- delete an unprocessed queued action if there is any ----//

	if( delActionRecno )
		nationPtr->del_action(delActionRecno);

	//--------- move to the camp now ---------//

	//-- if there is room in the camp to host all soldiers led by this general --//

	if( team_info->member_count-1 <= MAX_WORKER-bestCamp->worker_count )
	{
		validate_team();

		unit_array.assign( bestCamp->loc_x1, bestCamp->loc_y1, 0, COMMAND_AI,
								 team_info->member_unit_array, team_info->member_count );
		return 1;
	}
	else  //--- otherwise assign the general only ---//
	{
		return nationPtr->add_action(bestCamp->loc_x1, bestCamp->loc_y1, -1, -1, ACTION_AI_ASSIGN_OVERSEER, FIRM_CAMP, 1, sprite_recno);
	}

	return 0;
}
开发者ID:MicroVirus,项目名称:7kaa,代码行数:88,代码来源:OUNITAI.cpp

示例12: think_build_market

//-------- Begin of function Town::think_build_market ------//
//
int Town::think_build_market()
{
	if( info.game_date < setup_date + 90 )		// don't build the market too soon, as it may need to migrate to other town
		return 0;

	Nation* ownNation = nation_array[nation_recno];

	if( population < 10 + (100-ownNation->pref_trading_tendency)/20 )
		return 0;

	if( no_neighbor_space )		// if there is no space in the neighbor area for building a new firm.
		return 0;

	//--- check whether the AI can build a new firm next this firm ---//

	if( !ownNation->can_ai_build(FIRM_MARKET) )
		return 0;

	//----------------------------------------------------//
	// If there is already a firm queued for building with
	// a building location that is within the effective range
	// of the this firm.
	//----------------------------------------------------//

	if( ownNation->is_build_action_exist(FIRM_MARKET, center_x, center_y) )
		return 0;

	//-- only build one market place next to this mine, check if there is any existing one --//

	FirmMarket* firmPtr;

	for(int i=0; i<linked_firm_count; i++)
	{
		firmPtr = (FirmMarket*) firm_array[linked_firm_array[i]];

		if(firmPtr->firm_id!=FIRM_MARKET)
			continue;

		//------ if this market is our own one ------//

		if( firmPtr->nation_recno == nation_recno &&
			 ((FirmMarket*)firmPtr)->is_retail_market )
		{
			return 0;
		}
	}

	//------ queue building a new market -------//

	short buildXLoc, buildYLoc;

	if( !ownNation->find_best_firm_loc(FIRM_MARKET, loc_x1, loc_y1, buildXLoc, buildYLoc) )
	{
		no_neighbor_space = 1;
		return 0;
	}

	ownNation->add_action(buildXLoc, buildYLoc, loc_x1, loc_y1, ACTION_AI_BUILD_FIRM, FIRM_MARKET);

	return 1;
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:63,代码来源:OTOWNAI.cpp

示例13: think_ai_migrate

//------- Begin of function Town::think_ai_migrate --------//
//
// Think about migrating to another town.
//
int Town::think_ai_migrate()
{
	if( info.game_date < setup_date+90 )		// don't move if this town has just been set up for less than 90 days. It may be a town set up by think_split_town()
		return 0;

	Nation* nationPtr = nation_array[nation_recno];

	//-- the higher the loyalty, the higher the chance all the unit can be migrated --//

	int averageLoyalty = average_loyalty();
	int minMigrateLoyalty = 35 + nationPtr->pref_loyalty_concern/10;		// 35 to 45

	if( averageLoyalty < minMigrateLoyalty )
	{
		//-- if the total population is low (we need people) and the cash is high (we have money), then grant to increase loyalty for migration --//

		if( accumulated_reward_penalty==0 &&
			 average_target_loyalty() < minMigrateLoyalty+5 )		// if the average target loyalty is also lower than
		{
			if( nationPtr->ai_should_spend( 20+nationPtr->pref_territorial_cohesiveness/2 ) )		// 20 to 70 
				reward( COMMAND_AI );
		}

		if( average_loyalty() < minMigrateLoyalty )
			return 0;
	}

	if( !should_ai_migrate() )
		return 0;

	//------ think about which town to migrate to ------//

	int bestTownRecno = think_ai_migrate_to_town();

	if( !bestTownRecno )
		return 0;

	//--- check if there are already units currently migrating to the destination town ---//

	Town* destTownPtr = town_array[bestTownRecno];

	if( nationPtr->is_action_exist( destTownPtr->loc_x1, destTownPtr->loc_y1,
		 loc_x1, loc_y1, ACTION_AI_SETTLE_TO_OTHER_TOWN, 0, 0, 1 ) )		// last 1-check duplication on the destination town only
	{
		return 0;
	}

	//--------- queue for migration now ---------//

	int migrateCount = (average_loyalty() - MIN_RECRUIT_LOYALTY) / 5;

	migrateCount = min( migrateCount, jobless_population );

	if( migrateCount <= 0 )
		return 0;

	nationPtr->add_action( destTownPtr->loc_x1, destTownPtr->loc_y1,
		 loc_x1, loc_y1, ACTION_AI_SETTLE_TO_OTHER_TOWN, 0, migrateCount);

	return 1;
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:65,代码来源:OTOWNAI.cpp

示例14: think_build_factory


//.........这里部分代码省略.........
	Firm*			 firmMarket;

	for(int i=0; i<linked_firm_count; i++)
	{
		err_when(!linked_firm_array[i] || firm_array.is_deleted(linked_firm_array[i]));

		firmPtr = (FirmFactory*) firm_array[linked_firm_array[i]];

		if(firmPtr->firm_id!=FIRM_FACTORY)
			continue;

		if( firmPtr->nation_recno != nation_recno )
			continue;

		if( firmPtr->product_raw_id != rawId )
			continue;

		//--- if one of own factories still has not recruited enough workers ---//

		if( firmPtr->worker_count < MAX_WORKER )
			return 0;

		//---------------------------------------------------//
		//
		// If this factory has a medium to high level of stock,
		// this means the bottleneck is not at the factories,
		// building more factories won't solve the problem.
		//
		//---------------------------------------------------//

		if( firmPtr->stock_qty > firmPtr->max_stock_qty * 0.1 )
			return 0;

		//---------------------------------------------------//
		//
		// Check if this factory is just outputing goods to
		// a market and it is actually not overcapacity.
		//
		//---------------------------------------------------//

		for( int j=firmPtr->linked_firm_count-1 ; j>=0 ; j-- )
		{
			if( firmPtr->linked_firm_enable_array[j] != LINK_EE )
				continue;

			firmMarket = firm_array[ firmPtr->linked_firm_array[j] ];

			if( firmMarket->firm_id != FIRM_MARKET )
				continue;

			//--- if this factory is producing enough goods to the market place, then it means it is still quite efficient

			MarketGoods *marketGoods = ((FirmMarket*)firmMarket)->market_product_array[rawId-1];

			if( marketGoods && marketGoods->stock_qty > 100 )
				return 0;
		}

		//----------------------------------------------//

		factoryCount++;
	}

	//---- don't build additional factory if we don't have enough peasants ---//

	if( factoryCount>=1 && !nationPtr->ai_has_enough_food() )
		return 0;

	//-- if there isn't much raw reserve left, don't build new factories --//

	if( firm_id == FIRM_MINE )
	{
		if( ((FirmMine*)this)->reserve_qty < 1000 && factoryCount>=1 )
			return 0;
	}

	//--- only build additional factories if we have a surplus of labor ---//

	if( nationPtr->total_jobless_population < factoryCount * MAX_WORKER )
		return 0;

	//--- only when we have checked it three times and all say it needs a factory, we then build a factory ---//

	if( ++ai_should_build_factory_count >= 3 )
	{
		short buildXLoc, buildYLoc;

		if( !nationPtr->find_best_firm_loc(FIRM_FACTORY, loc_x1, loc_y1, buildXLoc, buildYLoc) )
		{
			no_neighbor_space = 1;
			return 0;
		}

		nationPtr->add_action(buildXLoc, buildYLoc, loc_x1, loc_y1, ACTION_AI_BUILD_FIRM, FIRM_FACTORY);

		ai_should_build_factory_count = 0;
	}

	return 1;
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:101,代码来源:OFIRMAI.cpp

示例15: ai_build_firm

//------- Begin of function FirmHarbor::ai_build_firm -----------//
//
int FirmHarbor::ai_build_firm(int firmId)
{
	if( no_neighbor_space )		// if there is no space in the neighbor area for building a new firm.
		return 0;

	Nation* ownNation = nation_array[nation_recno];

	//--- check whether the AI can build a new firm next this firm ---//

	if( !ownNation->can_ai_build(firmId) )
		return 0;

	//-- only build one market place next to this mine, check if there is any existing one --//

		//### begin alex 24/9 ###//
	/*FirmMarket* firmPtr;

	for(int i=0; i<linked_firm_count; i++)
	{
		err_when(!linked_firm_array[i] || firm_array.is_deleted(linked_firm_array[i]));

		firmPtr = (FirmMarket*) firm_array[linked_firm_array[i]];

		if( firmPtr->firm_id!=firmId )
			continue;

		//------ if this market is our own one ------//

		if( firmPtr->nation_recno == nation_recno )
			return 0;
	}*/
	Firm* firmPtr;

	for(int i=0; i<linked_firm_count; i++)
	{
		err_when(!linked_firm_array[i] || firm_array.is_deleted(linked_firm_array[i]));

		firmPtr = firm_array[linked_firm_array[i]];

		if( firmPtr->firm_id!=firmId )
			continue;

		//------ if this market is our own one ------//

		if( firmPtr->nation_recno == nation_recno )
			return 0;
	}
	//#### end alex 24/9 ####//

	//------ queue building a new market -------//

	short buildXLoc, buildYLoc;

	if( !ownNation->find_best_firm_loc(firmId, loc_x1, loc_y1, buildXLoc, buildYLoc) )
	{
		no_neighbor_space = 1;
		return 0;
	}

	ownNation->add_action(buildXLoc, buildYLoc, loc_x1, loc_y1, ACTION_AI_BUILD_FIRM, firmId);

	return 1;
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:65,代码来源:OF_HARB2.cpp


注:本文中的Nation::add_action方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。