* Process NewGRF string control code instructions. * @param scc The string control code that has been read. * @param consumer The string that we are reading from. * @param stack The TextRefStack. * @param[out] params Output parameters */
| 762 | * @param[out] params Output parameters |
| 763 | */ |
| 764 | static void ProcessNewGRFStringControlCode(char32_t scc, StringConsumer &consumer, TextRefStack &stack, std::vector<StringParameter> ¶ms) |
| 765 | { |
| 766 | /* There is data on the NewGRF text stack, and we want to move them to OpenTTD's string stack. |
| 767 | * After this call, a new call is made with `modify_parameters` set to false when the string is finally formatted. */ |
| 768 | switch (scc) { |
| 769 | default: return; |
| 770 | |
| 771 | case SCC_PLURAL_LIST: |
| 772 | consumer.SkipUint8(); // plural form |
| 773 | [[fallthrough]]; |
| 774 | case SCC_GENDER_LIST: { |
| 775 | consumer.SkipUint8(); // offset |
| 776 | /* plural and gender choices cannot contain any string commands, so just skip the whole thing */ |
| 777 | uint num = consumer.ReadUint8(); |
| 778 | uint total_len = 0; |
| 779 | for (uint i = 0; i != num; i++) { |
| 780 | total_len += consumer.ReadUint8(); |
| 781 | } |
| 782 | consumer.Skip(total_len); |
| 783 | break; |
| 784 | } |
| 785 | |
| 786 | case SCC_SWITCH_CASE: { |
| 787 | /* skip all cases and continue with default case */ |
| 788 | uint num = consumer.ReadUint8(); |
| 789 | for (uint i = 0; i != num; i++) { |
| 790 | consumer.SkipUint8(); |
| 791 | auto len = consumer.ReadUint16LE(); |
| 792 | consumer.Skip(len); |
| 793 | } |
| 794 | consumer.SkipUint16LE(); // length of default |
| 795 | break; |
| 796 | } |
| 797 | |
| 798 | case SCC_GENDER_INDEX: |
| 799 | case SCC_SET_CASE: |
| 800 | consumer.SkipUint8(); |
| 801 | break; |
| 802 | |
| 803 | case SCC_ARG_INDEX: |
| 804 | NOT_REACHED(); |
| 805 | break; |
| 806 | |
| 807 | case SCC_NEWGRF_PRINT_BYTE_SIGNED: params.emplace_back(stack.PopSignedByte()); break; |
| 808 | case SCC_NEWGRF_PRINT_QWORD_CURRENCY: params.emplace_back(stack.PopSignedQWord()); break; |
| 809 | |
| 810 | case SCC_NEWGRF_PRINT_DWORD_CURRENCY: |
| 811 | case SCC_NEWGRF_PRINT_DWORD_SIGNED: params.emplace_back(stack.PopSignedDWord()); break; |
| 812 | |
| 813 | case SCC_NEWGRF_PRINT_BYTE_HEX: params.emplace_back(stack.PopUnsignedByte()); break; |
| 814 | case SCC_NEWGRF_PRINT_QWORD_HEX: params.emplace_back(stack.PopUnsignedQWord()); break; |
| 815 | |
| 816 | case SCC_NEWGRF_PRINT_WORD_SPEED: |
| 817 | case SCC_NEWGRF_PRINT_WORD_VOLUME_LONG: |
| 818 | case SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT: |
| 819 | case SCC_NEWGRF_PRINT_WORD_SIGNED: params.emplace_back(stack.PopSignedWord()); break; |
| 820 | |
| 821 | case SCC_NEWGRF_PRINT_WORD_HEX: |
no test coverage detected