mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Don't crash on too large skins
This commit is contained in:
parent
4205775f38
commit
6a03660fb2
@ -134,9 +134,9 @@ namespace ClassicalSharp.Entities {
|
||||
EnsurePow2(ref bmp);
|
||||
SkinType = Utils.GetSkinType(bmp);
|
||||
|
||||
if (SkinType == SkinType.Invalid) {
|
||||
SetSkinAll(true);
|
||||
} else {
|
||||
if (bmp.Width > game.Graphics.MaxTexWidth || bmp.Height > game.Graphics.MaxTexHeight) {
|
||||
game.Chat.Add("&cSkin " + SkinName + " is too large");
|
||||
} else if (SkinType != SkinType.Invalid) {
|
||||
if (Model.UsesHumanSkin) ClearHat(bmp, SkinType);
|
||||
TextureId = game.Graphics.CreateTexture(bmp, true, false);
|
||||
SetSkinAll(false);
|
||||
|
12
src/Entity.c
12
src/Entity.c
@ -715,7 +715,7 @@ static void Player_CheckSkin(struct Player* p) {
|
||||
}
|
||||
p->FetchedSkin = true;
|
||||
}
|
||||
|
||||
|
||||
if (!AsyncDownloader_Get(&skin, &item)) return;
|
||||
if (!item.ResultData) { Player_SetSkinAll(p, true); return; }
|
||||
Stream_ReadonlyMemory(&mem, item.ResultData, item.ResultSize);
|
||||
@ -731,12 +731,10 @@ static void Player_CheckSkin(struct Player* p) {
|
||||
Player_EnsurePow2(p, &bmp);
|
||||
e->SkinType = Utils_GetSkinType(&bmp);
|
||||
|
||||
if (e->SkinType == SKIN_INVALID) {
|
||||
Player_SetSkinAll(p, true);
|
||||
} else {
|
||||
if (e->Model->UsesHumanSkin) {
|
||||
Player_ClearHat(&bmp, e->SkinType);
|
||||
}
|
||||
if (bmp.Width > Gfx_MaxTexWidth || bmp.Height > Gfx_MaxTexHeight) {
|
||||
Chat_Add1("&cSkin %s is too large", &skin);
|
||||
} else if (e->SkinType != SKIN_INVALID) {
|
||||
if (e->Model->UsesHumanSkin) Player_ClearHat(&bmp, e->SkinType);
|
||||
e->TextureId = Gfx_CreateTexture(&bmp, true, false);
|
||||
Player_SetSkinAll(p, false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user