MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ParseImages

Method ParseImages

src/openrct2/object/ImageTable.cpp:86–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 };
85
86 std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::ParseImages(IReadObjectContext* context, std::string s)
87 {
88 std::vector<std::unique_ptr<RequiredImage>> result;
89 if (s.empty())
90 {
91 result.push_back(std::make_unique<RequiredImage>());
92 }
93 else if (String::startsWith(s, "$CSG"))
94 {
95 auto rangeStart = s.find('[');
96 auto rangeEnd = s.find(']');
97 if (rangeStart != std::string::npos && rangeEnd != std::string::npos)
98 {
99 auto rangeString = s.substr(rangeStart, rangeEnd - rangeStart + 1);
100 auto range = ParseRange(rangeString);
101 if (IsCsgLoaded())
102 {
103 for (auto i : range)
104 {
105 result.push_back(
106 std::make_unique<RequiredImage>(
107 static_cast<uint32_t>(SPR_CSG_BEGIN + i),
108 [](uint32_t idx) -> const G1Element* { return GfxGetG1Element(idx); }));
109 }
110 }
111 else
112 {
113 std::string id(context->GetObjectIdentifier());
114 LOG_WARNING("CSG not loaded inserting placeholder images for %s", id.c_str());
115 result.resize(range.size());
116 for (auto& res : result)
117 {
118 res = std::make_unique<RequiredImage>();
119 }
120 }
121 }
122 }
123 else if (String::startsWith(s, "$G1"))
124 {
125 auto rangeStart = s.find('[');
126 auto rangeEnd = s.find(']');
127 if (rangeStart != std::string::npos && rangeEnd != std::string::npos)
128 {
129 auto rangeString = s.substr(rangeStart, rangeEnd - rangeStart + 1);
130 auto range = ParseRange(rangeString);
131 for (auto i : range)
132 {
133 result.push_back(
134 std::make_unique<RequiredImage>(
135 static_cast<uint32_t>(i), [](uint32_t idx) -> const G1Element* { return GfxGetG1Element(idx); }));
136 }
137 }
138 }
139 else if (String::startsWith(s, "$RCT2:OBJDATA/"))
140 {
141 auto name = s.substr(14);
142 auto rangeStart = name.find('[');
143 auto rangeEnd = name.find(']');

Callers

nothing calls this directly

Calls 15

startsWithFunction · 0.85
IsCsgLoadedFunction · 0.85
GfxGetG1ElementFunction · 0.85
ReadFromBufferFunction · 0.85
stdFormatFunction · 0.85
AssertFunction · 0.85
GetStringFunction · 0.85
findMethod · 0.80
endMethod · 0.65
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected