View difference between Paste ID: uVsah43X and 2Lggjucm
SHOW: | | - or go back to the newest paste.
1
	/** Apply ocean/canal speed fraction to a velocity */
2
	uint ApplyWaterClassSpeedFrac(uint raw_speed, WaterDepth depth) const
3
	{
4
		bool is_ocean = depth >= WATER_DEPTH_DEEP;
5-
		uint depth_diff = WATER_DEPTH_MAX - depth;
5+
		WaterDepth depth_diff = WATER_DEPTH_MAX - depth;
6-
		byte speed_frac = is_ocean ? this->ocean_speed_frac + depth_diff : this->canal_speed_frac + depth_diff;
6+
		byte speed_frac = min(256, is_ocean ? this->ocean_speed_frac + depth_diff : this->canal_speed_frac + depth_diff);
7
		/* speed_frac == 0 means no reduction while 0xFF means reduction to 1/256. */
8-
		return raw_speed * (256 - (min(256, speed_frac))) / 256;
8+
		return raw_speed * (256 - speed_frac) / 256;
9
	}