← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/bug-1729856 into lp:widelands

 

Review: Approve

LGTM, 1 nit. Do you want to change the exception back to an assert?

Diff comments:

> === modified file 'src/ai/defaultai_warfare.cc'
> --- src/ai/defaultai_warfare.cc	2017-11-02 19:55:17 +0000
> +++ src/ai/defaultai_warfare.cc	2017-11-04 20:46:09 +0000
> @@ -576,14 +576,24 @@
>  	TrainingSiteObserver& tso = trainingsites.front();
>  
>  	// Make sure we are not above ai type limit
> -	assert(tso.bo->total_count() <= tso.bo->cnt_limit_by_aimode);
> +	if (tso.bo->total_count() > tso.bo->cnt_limit_by_aimode) {
> +		throw wexception("%d AI count of %s exceeds an AI limit %d: actual count: %d\n",
> +		                 player_number(), tso.bo->name, tso.bo->cnt_limit_by_aimode,
> +		                 tso.bo->total_count());
> +	}
>  
>  	const DescriptionIndex enhancement = ts->descr().enhancement();
>  
>  	if (enhancement != INVALID_INDEX && ts_without_trainers_ == 0 && mines_.size() > 3 &&
>  	    ts_finished_count_ > 1 && ts_in_const_count_ == 0) {
>  
> -		if (player_->is_building_type_allowed(enhancement)) {
> +		// Make sure that"

// Make sure that" -> // Make sure that

> +		// 1. Building is allowed
> +		// 2. AI limit for weaker AI is not to be exceeded
> +		BuildingObserver& en_bo =
> +		   get_building_observer(tribe_->get_building_descr(enhancement)->name().c_str());
> +		if (player_->is_building_type_allowed(enhancement) &&
> +		    en_bo.aimode_limit_status() == AiModeBuildings::kAnotherAllowed) {
>  			game().send_player_enhance_building(*tso.site, enhancement);
>  		}
>  	}


-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1729856/+merge/333230
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1729856.


References