MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / ApplySkin

Function ApplySkin

src/Entity.c:339–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337}
338
339static cc_result ApplySkin(struct Entity* e, struct Bitmap* bmp, struct Stream* src, cc_string* skin) {
340 cc_result res;
341 if ((res = Png_Decode(bmp, src))) return res;
342
343 Gfx_DeleteTexture(&e->TextureId);
344 if ((res = EnsurePow2Skin(e, bmp))) return res;
345 e->SkinType = Utils_CalcSkinType(bmp);
346
347 if (!Gfx_CheckTextureSize(bmp->width, bmp->height, 0)) {
348 Chat_Add1("&cSkin %s is too large", skin);
349 } else {
350 if (e->Model->flags & MODEL_FLAG_CLEAR_HAT)
351 Entity_ClearHat(bmp, e->SkinType);
352
353 e->TextureId = Gfx_CreateTexture(bmp, TEXTURE_FLAG_MANAGED, false);
354 Entity_SetSkinAll(e, false);
355 }
356 return 0;
357}
358
359static void LogInvalidSkin(cc_result res, const cc_string* skin, const cc_uint8* data, int size) {
360 cc_string msg; char msgBuffer[256];

Callers 1

CheckSkin_DownloadingFunction · 0.85

Calls 9

Png_DecodeFunction · 0.85
EnsurePow2SkinFunction · 0.85
Utils_CalcSkinTypeFunction · 0.85
Gfx_CheckTextureSizeFunction · 0.85
Chat_Add1Function · 0.85
Entity_ClearHatFunction · 0.85
Gfx_CreateTextureFunction · 0.85
Entity_SetSkinAllFunction · 0.85
Gfx_DeleteTextureFunction · 0.70

Tested by

no test coverage detected