MCPcopy Create free account
hub / github.com/ddnet/ddnet / SkinScan

Method SkinScan

src/game/client/components/skins.cpp:220–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218};
219
220int CSkins::SkinScan(const char *pName, int IsDir, int StorageType, void *pUser)
221{
222 auto *pUserReal = static_cast<CSkinScanUser *>(pUser);
223 CSkins *pSelf = pUserReal->m_pThis;
224
225 if(IsDir)
226 {
227 return 0;
228 }
229
230 const char *pSuffix = str_endswith(pName, ".png");
231 if(pSuffix == nullptr)
232 {
233 return 0;
234 }
235
236 char aSkinName[IO_MAX_PATH_LENGTH];
237 str_truncate(aSkinName, sizeof(aSkinName), pName, pSuffix - pName);
238 if(!CSkin::IsValidName(aSkinName))
239 {
240 log_error("skins", "Skin name is not valid: %s", aSkinName);
241 log_error("skins", "%s", CSkin::m_aSkinNameRestrictions);
242 return 0;
243 }
244
245 CSkinContainer SkinContainer(pSelf, aSkinName, CSkinContainer::EType::LOCAL, StorageType);
246 auto &&pSkinContainer = std::make_unique<CSkinContainer>(std::move(SkinContainer));
247 pSkinContainer->SetState(pSkinContainer->DetermineInitialState());
248 pSelf->m_Skins.insert({pSkinContainer->Name(), std::move(pSkinContainer)});
249 pUserReal->m_SkinLoadedCallback();
250 return 0;
251}
252
253static void CheckMetrics(CSkin::CSkinMetricVariable &Metrics, const uint8_t *pImg, int ImgWidth, int ImgX, int ImgY, int CheckWidth, int CheckHeight)
254{

Callers

nothing calls this directly

Calls 5

str_endswithFunction · 0.85
str_truncateFunction · 0.85
DetermineInitialStateMethod · 0.80
SetStateMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected