(svn r23945) -Fix: Better rounding when converting internal speed to displayed speed.
This commit is contained in:
		@@ -682,6 +682,25 @@ uint ConvertDisplaySpeedToSpeed(uint speed)
 | 
				
			|||||||
	return _units[_settings_game.locale.units].c_velocity.FromDisplay(speed);
 | 
						return _units[_settings_game.locale.units].c_velocity.FromDisplay(speed);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Convert the given km/h-ish speed to the display speed.
 | 
				
			||||||
 | 
					 * @param speed the speed to convert
 | 
				
			||||||
 | 
					 * @return the converted speed.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					uint ConvertKmhishSpeedToDisplaySpeed(uint speed)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return _units[_settings_game.locale.units].c_velocity.ToDisplay(speed * 10, false) / 16;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Convert the given display speed to the km/h-ish speed.
 | 
				
			||||||
 | 
					 * @param speed the speed to convert
 | 
				
			||||||
 | 
					 * @return the converted speed.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					uint ConvertDisplaySpeedToKmhishSpeed(uint speed)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return _units[_settings_game.locale.units].c_velocity.FromDisplay(speed * 16) / 10;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Parse most format codes within a string and write the result to a buffer.
 | 
					 * Parse most format codes within a string and write the result to a buffer.
 | 
				
			||||||
 * @param buff  The buffer to write the final string to.
 | 
					 * @param buff  The buffer to write the final string to.
 | 
				
			||||||
@@ -1137,7 +1156,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			case SCC_VELOCITY: { // {VELOCITY}
 | 
								case SCC_VELOCITY: { // {VELOCITY}
 | 
				
			||||||
				assert(_settings_game.locale.units < lengthof(_units));
 | 
									assert(_settings_game.locale.units < lengthof(_units));
 | 
				
			||||||
				int64 args_array[] = {ConvertSpeedToDisplaySpeed(args->GetInt64(SCC_VELOCITY) * 10 / 16)};
 | 
									int64 args_array[] = {ConvertKmhishSpeedToDisplaySpeed(args->GetInt64(SCC_VELOCITY))};
 | 
				
			||||||
				StringParameters tmp_params(args_array);
 | 
									StringParameters tmp_params(args_array);
 | 
				
			||||||
				buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].velocity), &tmp_params, last);
 | 
									buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].velocity), &tmp_params, last);
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -141,6 +141,9 @@ char *GetString(char *buffr, StringID string, const char *last);
 | 
				
			|||||||
char *GetStringWithArgs(char *buffr, StringID string, StringParameters *args, const char *last, uint case_index = 0, bool game_script = false);
 | 
					char *GetStringWithArgs(char *buffr, StringID string, StringParameters *args, const char *last, uint case_index = 0, bool game_script = false);
 | 
				
			||||||
const char *GetStringPtr(StringID string);
 | 
					const char *GetStringPtr(StringID string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint ConvertKmhishSpeedToDisplaySpeed(uint speed);
 | 
				
			||||||
 | 
					uint ConvertDisplaySpeedToKmhishSpeed(uint speed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void InjectDParam(uint amount);
 | 
					void InjectDParam(uint amount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user