MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ParseStringChoice

Function ParseStringChoice

src/strings.cpp:787–806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

785}
786
787static void ParseStringChoice(StringConsumer &consumer, uint form, StringBuilder &builder)
788{
789 /* <NUM> {Length of each string} {each string} */
790 uint n = consumer.ReadUint8();
791 size_t form_pre = 0, form_len = 0, form_post = 0;
792 for (uint i = 0; i != n; i++) {
793 uint len = consumer.ReadUint8();
794 if (i < form) {
795 form_pre += len;
796 } else if (i > form) {
797 form_post += len;
798 } else {
799 form_len = len;
800 }
801 }
802
803 consumer.Skip(form_pre);
804 builder += consumer.Read(form_len);
805 consumer.Skip(form_post);
806}
807
808/** Helper for unit conversion. */
809struct UnitConversion {

Callers 1

FormatStringFunction · 0.85

Calls 3

ReadUint8Method · 0.80
SkipMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected