| 337 | } |
| 338 | |
| 339 | static 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 | |
| 359 | static void LogInvalidSkin(cc_result res, const cc_string* skin, const cc_uint8* data, int size) { |
| 360 | cc_string msg; char msgBuffer[256]; |
no test coverage detected