mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -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);
|
EnsurePow2(ref bmp);
|
||||||
SkinType = Utils.GetSkinType(bmp);
|
SkinType = Utils.GetSkinType(bmp);
|
||||||
|
|
||||||
if (SkinType == SkinType.Invalid) {
|
if (bmp.Width > game.Graphics.MaxTexWidth || bmp.Height > game.Graphics.MaxTexHeight) {
|
||||||
SetSkinAll(true);
|
game.Chat.Add("&cSkin " + SkinName + " is too large");
|
||||||
} else {
|
} else if (SkinType != SkinType.Invalid) {
|
||||||
if (Model.UsesHumanSkin) ClearHat(bmp, SkinType);
|
if (Model.UsesHumanSkin) ClearHat(bmp, SkinType);
|
||||||
TextureId = game.Graphics.CreateTexture(bmp, true, false);
|
TextureId = game.Graphics.CreateTexture(bmp, true, false);
|
||||||
SetSkinAll(false);
|
SetSkinAll(false);
|
||||||
|
10
src/Entity.c
10
src/Entity.c
@ -731,12 +731,10 @@ static void Player_CheckSkin(struct Player* p) {
|
|||||||
Player_EnsurePow2(p, &bmp);
|
Player_EnsurePow2(p, &bmp);
|
||||||
e->SkinType = Utils_GetSkinType(&bmp);
|
e->SkinType = Utils_GetSkinType(&bmp);
|
||||||
|
|
||||||
if (e->SkinType == SKIN_INVALID) {
|
if (bmp.Width > Gfx_MaxTexWidth || bmp.Height > Gfx_MaxTexHeight) {
|
||||||
Player_SetSkinAll(p, true);
|
Chat_Add1("&cSkin %s is too large", &skin);
|
||||||
} else {
|
} else if (e->SkinType != SKIN_INVALID) {
|
||||||
if (e->Model->UsesHumanSkin) {
|
if (e->Model->UsesHumanSkin) Player_ClearHat(&bmp, e->SkinType);
|
||||||
Player_ClearHat(&bmp, e->SkinType);
|
|
||||||
}
|
|
||||||
e->TextureId = Gfx_CreateTexture(&bmp, true, false);
|
e->TextureId = Gfx_CreateTexture(&bmp, true, false);
|
||||||
Player_SetSkinAll(p, false);
|
Player_SetSkinAll(p, false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user