Loading

Paste #pvetrqwje

  1. Index: src/strings.cpp
  2. ===================================================================
  3. --- src/strings.cpp (revision 23944)
  4. +++ src/strings.cpp (revision 23945)
  5. @@ -683,6 +683,25 @@
  6.  }
  7.  
  8.  /**
  9. + * Convert the given km/h-ish speed to the display speed.
  10. + * @param speed the speed to convert
  11. + * @return the converted speed.
  12. + */
  13. +uint ConvertKmhishSpeedToDisplaySpeed(uint speed)
  14. +{
  15. +   return _units[_settings_game.locale.units].c_velocity.ToDisplay(speed * 10, false) / 16;
  16. +}
  17. +
  18. +/**
  19. + * Convert the given display speed to the km/h-ish speed.
  20. + * @param speed the speed to convert
  21. + * @return the converted speed.
  22. + */
  23. +uint ConvertDisplaySpeedToKmhishSpeed(uint speed)
  24. +{
  25. +   return _units[_settings_game.locale.units].c_velocity.FromDisplay(speed * 16) / 10;
  26. +}
  27. +/**
  28.   * Parse most format codes within a string and write the result to a buffer.
  29.   * @param buff  The buffer to write the final string to.
  30.   * @param str   The original string with format codes.
  31. @@ -1137,7 +1156,7 @@
  32.  
  33.             case SCC_VELOCITY: { // {VELOCITY}
  34.                 assert(_settings_game.locale.units < lengthof(_units));
  35. -               int64 args_array[] = {ConvertSpeedToDisplaySpeed(args->GetInt64(SCC_VELOCITY) * 10 / 16)};
  36. +               int64 args_array[] = {ConvertKmhishSpeedToDisplaySpeed(args->GetInt64(SCC_VELOCITY))};
  37.                 StringParameters tmp_params(args_array);
  38.                 buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].velocity), &tmp_params, last);
  39.                 break;

Comments