534 1, 0, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI, |
534 1, 0, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI, |
535 1, 0, STR_UNITS_FORCE_SI, |
535 1, 0, STR_UNITS_FORCE_SI, |
536 }, |
536 }, |
537 }; |
537 }; |
538 |
538 |
|
539 /** |
|
540 * Convert the given (internal) speed to the display speed. |
|
541 * @param speed the speed to convert |
|
542 * @return the converted speed. |
|
543 */ |
|
544 uint ConvertSpeedToDisplaySpeed(uint speed) |
|
545 { |
|
546 return (speed * units[_opt_ptr->units].s_m) >> units[_opt_ptr->units].s_s; |
|
547 } |
|
548 |
|
549 /** |
|
550 * Convert the given display speed to the (internal) speed. |
|
551 * @param speed the speed to convert |
|
552 * @return the converted speed. |
|
553 */ |
|
554 uint ConvertDisplaySpeedToSpeed(uint speed) |
|
555 { |
|
556 return ((speed << units[_opt_ptr->units].s_s) + units[_opt_ptr->units].s_m / 2) / units[_opt_ptr->units].s_m; |
|
557 } |
|
558 |
539 static char* FormatString(char* buff, const char* str, const int64* argv, uint casei, const char* last) |
559 static char* FormatString(char* buff, const char* str, const int64* argv, uint casei, const char* last) |
540 { |
560 { |
541 extern const char _openttd_revision[]; |
561 extern const char _openttd_revision[]; |
542 WChar b; |
562 WChar b; |
543 const int64 *argv_orig = argv; |
563 const int64 *argv_orig = argv; |
579 break; |
599 break; |
580 |
600 |
581 case SCC_VELOCITY: {// {VELOCITY} |
601 case SCC_VELOCITY: {// {VELOCITY} |
582 int64 args[1]; |
602 int64 args[1]; |
583 assert(_opt_ptr->units < lengthof(units)); |
603 assert(_opt_ptr->units < lengthof(units)); |
584 args[0] = GetInt32(&argv) * units[_opt_ptr->units].s_m >> units[_opt_ptr->units].s_s; |
604 args[0] = ConvertSpeedToDisplaySpeed(GetInt32(&argv)); |
585 buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].velocity), args, modifier >> 24, last); |
605 buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].velocity), args, modifier >> 24, last); |
586 modifier = 0; |
606 modifier = 0; |
587 break; |
607 break; |
588 } |
608 } |
589 |
609 |