0x004958C6
| 586 | |
| 587 | // 0x004958C6 |
| 588 | static void formatStringImpl(StringBuffer& buffer, StringId id, FormatArgumentsView& args) |
| 589 | { |
| 590 | if (id < kUserStringsStart) |
| 591 | { |
| 592 | const char* sourceStr = getString(id); |
| 593 | if (sourceStr == nullptr) |
| 594 | { |
| 595 | buffer.format(std::locale(), "(missing string id: {})", id); |
| 596 | Logging::warn("formatString: nullptr for string id: {}", id); |
| 597 | return; |
| 598 | } |
| 599 | |
| 600 | formatStringPart(buffer, sourceStr, args); |
| 601 | } |
| 602 | else if (id < kUserStringsEnd) |
| 603 | { |
| 604 | id -= kUserStringsStart; |
| 605 | args.skip<uint16_t>(); |
| 606 | const char* sourceStr = getUserString(id); |
| 607 | |
| 608 | buffer.append(sourceStr, kUserStringSize); |
| 609 | } |
| 610 | else if (id < kTownNamesEnd) |
| 611 | { |
| 612 | id -= kTownNamesStart; |
| 613 | |
| 614 | const auto townId = TownId(args.pop<uint16_t>()); |
| 615 | auto town = TownManager::get(townId); |
| 616 | |
| 617 | // TODO: Clean this up once we have only FormatArguments. |
| 618 | FormatArgumentsBuffer buf; |
| 619 | auto fmt = FormatArguments(buf); |
| 620 | fmt.push(town->name); |
| 621 | |
| 622 | auto fmtView = FormatArgumentsView(fmt); |
| 623 | formatStringImpl(buffer, id, fmtView); |
| 624 | } |
| 625 | else if (id == kTownNamesEnd) |
| 626 | { |
| 627 | const auto townId = TownId(args.pop<uint16_t>()); |
| 628 | auto town = TownManager::get(townId); |
| 629 | formatString(buffer, town->name); |
| 630 | } |
| 631 | else |
| 632 | { |
| 633 | buffer.format(std::locale(), "(invalid string id: {})", id); |
| 634 | Logging::warn("formatString: invalid string id: {}", id); |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | static void formatString(StringBuffer& buffer, StringId id) |
| 639 | { |
no test coverage detected