Index: src/strings.cpp =================================================================== --- src/strings.cpp (revision 21790) +++ src/strings.cpp (working copy) @@ -542,52 +542,52 @@ struct Units { int s_m; ///< Multiplier for velocity - int s_s; ///< Shift for velocity + int s_d; ///< Divisor for velocity StringID velocity; ///< String for velocity int p_m; ///< Multiplier for power - int p_s; ///< Shift for power + int p_d; ///< Divisor for power StringID power; ///< String for velocity int w_m; ///< Multiplier for weight - int w_s; ///< Shift for weight + int w_d; ///< Divisor for weight StringID s_weight; ///< Short string for weight StringID l_weight; ///< Long string for weight int v_m; ///< Multiplier for volume - int v_s; ///< Shift for volume + int v_d; ///< Divisor for volume StringID s_volume; ///< Short string for volume StringID l_volume; ///< Long string for volume int f_m; ///< Multiplier for force - int f_s; ///< Shift for force + int f_d; ///< Divisor for force StringID force; ///< String for force int h_m; ///< Multiplier for height - int h_s; ///< Shift for height + int h_d; ///< Divisor for height StringID height; ///< String for height }; /* Unit conversions */ static const Units units[] = { { // Imperial (Original, mph, hp, metric ton, litre, kN, ft) - 1, 0, STR_UNITS_VELOCITY_IMPERIAL, - 1, 0, STR_UNITS_POWER_IMPERIAL, - 1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC, - 1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC, - 1, 0, STR_UNITS_FORCE_SI, - 3, 0, STR_UNITS_HEIGHT_IMPERIAL, + 1, 1, STR_UNITS_VELOCITY_IMPERIAL, + 1, 1, STR_UNITS_POWER_IMPERIAL, + 1, 1, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC, + 1000, 1, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC, + 1, 1, STR_UNITS_FORCE_SI, + 3, 1, STR_UNITS_HEIGHT_IMPERIAL, }, { // Metric (km/h, hp, metric ton, litre, kN, metre) - 103, 6, STR_UNITS_VELOCITY_METRIC, - 1, 0, STR_UNITS_POWER_METRIC, - 1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC, - 1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC, - 1, 0, STR_UNITS_FORCE_SI, - 1, 0, STR_UNITS_HEIGHT_SI, + 103, 64, STR_UNITS_VELOCITY_METRIC, + 1, 1, STR_UNITS_POWER_METRIC, + 1, 1, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC, + 1000, 1, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC, + 1, 1, STR_UNITS_FORCE_SI, + 1, 1, STR_UNITS_HEIGHT_SI, }, { // SI (m/s, kilowatt, kilogram, cubic metre, kilonewton, metre) - 1831, 12, STR_UNITS_VELOCITY_SI, - 764, 10, STR_UNITS_POWER_SI, - 1000, 0, STR_UNITS_WEIGHT_SHORT_SI, STR_UNITS_WEIGHT_LONG_SI, - 1, 0, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI, - 1, 0, STR_UNITS_FORCE_SI, - 1, 0, STR_UNITS_HEIGHT_SI, + 1831, 4096, STR_UNITS_VELOCITY_SI, + 764, 1024, STR_UNITS_POWER_SI, + 1000, 1, STR_UNITS_WEIGHT_SHORT_SI, STR_UNITS_WEIGHT_LONG_SI, + 1, 1, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI, + 1, 1, STR_UNITS_FORCE_SI, + 1, 1, STR_UNITS_HEIGHT_SI, }, }; @@ -598,7 +598,7 @@ */ uint ConvertSpeedToDisplaySpeed(uint speed) { - return (speed * units[_settings_game.locale.units].s_m) >> units[_settings_game.locale.units].s_s; + return (speed * units[_settings_game.locale.units].s_m) / units[_settings_game.locale.units].s_d; } /** @@ -608,7 +608,7 @@ */ uint ConvertDisplaySpeedToSpeed(uint speed) { - return ((speed << units[_settings_game.locale.units].s_s) + units[_settings_game.locale.units].s_m / 2) / units[_settings_game.locale.units].s_m; + return ((speed * units[_settings_game.locale.units].s_d) + units[_settings_game.locale.units].s_m / 2) / units[_settings_game.locale.units].s_m; } /** @@ -697,7 +697,7 @@ } case SCC_HEIGHT: { // {HEIGHT} - int64 args[1] = {GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].h_m >> units[_settings_game.locale.units].h_s}; + int64 args[1] = {GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].h_m / units[_settings_game.locale.units].h_d}; buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].height), args, endof(args), modifier >> 24, last); modifier = 0; break; @@ -720,7 +720,7 @@ case STR_TONS: { int64 args[1]; assert(_settings_game.locale.units < lengthof(units)); - args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].w_m >> units[_settings_game.locale.units].w_s; + args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].w_m / units[_settings_game.locale.units].w_d; buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].l_weight), args, endof(args), modifier >> 24, last); modifier = 0; break; @@ -729,7 +729,7 @@ case STR_LITERS: { int64 args[1]; assert(_settings_game.locale.units < lengthof(units)); - args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].v_m >> units[_settings_game.locale.units].v_s; + args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].v_m / units[_settings_game.locale.units].v_d; buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].l_volume), args, endof(args), modifier >> 24, last); modifier = 0; break; @@ -815,7 +815,7 @@ case SCC_VOLUME: { // {VOLUME} int64 args[1]; assert(_settings_game.locale.units < lengthof(units)); - args[0] = GetInt32(&argv, argve, &argt, SCC_VOLUME) * units[_settings_game.locale.units].v_m >> units[_settings_game.locale.units].v_s; + args[0] = GetInt32(&argv, argve, &argt, SCC_VOLUME) * units[_settings_game.locale.units].v_m / units[_settings_game.locale.units].v_d; buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].l_volume), args, endof(args), modifier >> 24, last); modifier = 0; break; @@ -873,7 +873,7 @@ case SCC_POWER: { // {POWER} int64 args[1]; assert(_settings_game.locale.units < lengthof(units)); - args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].p_m >> units[_settings_game.locale.units].p_s; + args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].p_m / units[_settings_game.locale.units].p_d; buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].power), args, endof(args), modifier >> 24, last); modifier = 0; break; @@ -882,7 +882,7 @@ case SCC_VOLUME_SHORT: { // {VOLUME_S} int64 args[1]; assert(_settings_game.locale.units < lengthof(units)); - args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].v_m >> units[_settings_game.locale.units].v_s; + args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].v_m / units[_settings_game.locale.units].v_d; buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].s_volume), args, endof(args), modifier >> 24, last); modifier = 0; break; @@ -891,7 +891,7 @@ case SCC_WEIGHT: { // {WEIGHT} int64 args[1]; assert(_settings_game.locale.units < lengthof(units)); - args[0] = GetInt32(&argv, argve, &argt, SCC_WEIGHT) * units[_settings_game.locale.units].w_m >> units[_settings_game.locale.units].w_s; + args[0] = GetInt32(&argv, argve, &argt, SCC_WEIGHT) * units[_settings_game.locale.units].w_m / units[_settings_game.locale.units].w_d; buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].l_weight), args, endof(args), modifier >> 24, last); modifier = 0; break; @@ -900,7 +900,7 @@ case SCC_WEIGHT_SHORT: { // {WEIGHT_S} int64 args[1]; assert(_settings_game.locale.units < lengthof(units)); - args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].w_m >> units[_settings_game.locale.units].w_s; + args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].w_m / units[_settings_game.locale.units].w_d; buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].s_weight), args, endof(args), modifier >> 24, last); modifier = 0; break; @@ -909,7 +909,7 @@ case SCC_FORCE: { // {FORCE} int64 args[1]; assert(_settings_game.locale.units < lengthof(units)); - args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].f_m >> units[_settings_game.locale.units].f_s; + args[0] = GetInt32(&argv, argve, &argt) * units[_settings_game.locale.units].f_m / units[_settings_game.locale.units].f_d; buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].force), args, endof(args), modifier >> 24, last); modifier = 0; break;