mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 04:26:52 -04:00
Don't store full model name in C client for entity, reduces size of net players list global by 3 KB
This commit is contained in:
parent
58c7a3a5cd
commit
a66e4a7e6a
@ -356,10 +356,10 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
input.EnterInput();
|
input.EnterInput();
|
||||||
altText.SetActive(false);
|
altText.SetActive(false);
|
||||||
|
|
||||||
// Do we need to move all chat down?
|
// Reset chat when user has scrolled up in chat history
|
||||||
int resetIndex = game.Chat.Log.Count - chatLines;
|
int defaultIndex = game.Chat.Log.Count - chatLines;
|
||||||
if (chatIndex != resetIndex) {
|
if (chatIndex != defaultIndex) {
|
||||||
chatIndex = ClampIndex(resetIndex);
|
chatIndex = ClampIndex(defaultIndex);
|
||||||
ResetChat();
|
ResetChat();
|
||||||
}
|
}
|
||||||
} else if (key == Key.PageUp) {
|
} else if (key == Key.PageUp) {
|
||||||
|
@ -127,7 +127,6 @@ void Entity_ParseScale(Entity* entity, String scale) {
|
|||||||
void Entity_SetModel(Entity* entity, STRING_PURE String* model) {
|
void Entity_SetModel(Entity* entity, STRING_PURE String* model) {
|
||||||
entity->ModelScale = Vector3_Create1(1.0f);
|
entity->ModelScale = Vector3_Create1(1.0f);
|
||||||
entity->ModelBlock = BLOCK_AIR;
|
entity->ModelBlock = BLOCK_AIR;
|
||||||
String entModel = String_InitAndClearArray(entity->ModelNameRaw);
|
|
||||||
|
|
||||||
Int32 sep = String_IndexOf(model, '|', 0);
|
Int32 sep = String_IndexOf(model, '|', 0);
|
||||||
String name, scale;
|
String name, scale;
|
||||||
@ -141,20 +140,19 @@ void Entity_SetModel(Entity* entity, STRING_PURE String* model) {
|
|||||||
|
|
||||||
/* 'giant' model kept for backwards compatibility */
|
/* 'giant' model kept for backwards compatibility */
|
||||||
if (String_CaselessEqualsConst(model, "giant")) {
|
if (String_CaselessEqualsConst(model, "giant")) {
|
||||||
String_AppendConst(&entModel, "humanoid");
|
name = String_FromReadonly("humanoid");
|
||||||
entity->ModelScale = Vector3_Create1(2.0f);
|
entity->ModelScale = Vector3_Create1(2.0f);
|
||||||
} else if (Convert_TryParseUInt8(model, &entity->ModelBlock)) {
|
} else if (Convert_TryParseUInt8(model, &entity->ModelBlock)) {
|
||||||
String_AppendConst(&entModel, "block");
|
name = String_FromReadonly("block");
|
||||||
} else {
|
|
||||||
String_AppendString(&entModel, &name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entity->Model = ModelCache_Get(&entModel);
|
entity->Model = ModelCache_Get(&name);
|
||||||
Entity_ParseScale(entity, scale);
|
Entity_ParseScale(entity, scale);
|
||||||
entity->MobTextureId = NULL;
|
entity->MobTextureId = NULL;
|
||||||
|
|
||||||
entity->Model->RecalcProperties(entity);
|
entity->Model->RecalcProperties(entity);
|
||||||
Entity_UpdateModelBounds(entity);
|
Entity_UpdateModelBounds(entity);
|
||||||
|
entity->ModelIsSheepNoFur = String_CaselessEqualsConst(&name, "sheep_nofur");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity_UpdateModelBounds(Entity* entity) {
|
void Entity_UpdateModelBounds(Entity* entity) {
|
||||||
|
@ -73,8 +73,8 @@ typedef struct Entity_ {
|
|||||||
Vector3 Velocity, OldVelocity;
|
Vector3 Velocity, OldVelocity;
|
||||||
|
|
||||||
IModel* Model;
|
IModel* Model;
|
||||||
UInt8 ModelNameRaw[String_BufferSize(ENTITY_MAX_MODEL_LENGTH)];
|
|
||||||
BlockID ModelBlock; /* BlockID, if model name was originally a vaid block id. */
|
BlockID ModelBlock; /* BlockID, if model name was originally a vaid block id. */
|
||||||
|
bool ModelIsSheepNoFur; /* Hacky, but only sheep model relies on model name. So use just 1 byte. */
|
||||||
AABB ModelAABB;
|
AABB ModelAABB;
|
||||||
Vector3 ModelScale, Size;
|
Vector3 ModelScale, Size;
|
||||||
Real32 StepSize;
|
Real32 StepSize;
|
||||||
|
@ -420,9 +420,7 @@ void SheepModel_DrawModel(Entity* entity) {
|
|||||||
IModel_DrawRotate(entity->Anim.LeftLegX, 0, 0, Sheep_RightLegBack, false);
|
IModel_DrawRotate(entity->Anim.LeftLegX, 0, 0, Sheep_RightLegBack, false);
|
||||||
IModel_UpdateVB();
|
IModel_UpdateVB();
|
||||||
|
|
||||||
String entModel = String_FromRawArray(entity->ModelNameRaw);
|
if (entity->ModelIsSheepNoFur) return;
|
||||||
String sheep_nofur = String_FromConst("sheep_nofur");
|
|
||||||
if (String_CaselessEquals(&entModel, &sheep_nofur)) return;
|
|
||||||
Gfx_BindTexture(ModelCache_Textures[fur_Index].TexID);
|
Gfx_BindTexture(ModelCache_Textures[fur_Index].TexID);
|
||||||
IModel_DrawRotate(-entity->HeadX * MATH_DEG2RAD, 0, 0, Fur_Head, true);
|
IModel_DrawRotate(-entity->HeadX * MATH_DEG2RAD, 0, 0, Fur_Head, true);
|
||||||
|
|
||||||
|
@ -876,10 +876,10 @@ bool ChatScreen_HandlesKeyDown(GuiElement* elem, Key key) {
|
|||||||
screen->Input.Base.OnPressedEnter(elem);
|
screen->Input.Base.OnPressedEnter(elem);
|
||||||
SpecialInputWidget_SetActive(&screen->AltText, false);
|
SpecialInputWidget_SetActive(&screen->AltText, false);
|
||||||
|
|
||||||
/* Do we need to move all chat down? */
|
/* Reset chat when user has scrolled up in chat history */
|
||||||
Int32 resetIndex = Chat_Log.Count - Game_ChatLines;
|
Int32 defaultIndex = Chat_Log.Count - Game_ChatLines;
|
||||||
if (screen->ChatIndex != resetIndex) {
|
if (screen->ChatIndex != defaultIndex) {
|
||||||
screen->ChatIndex = ChatScreen_ClampIndex(resetIndex);
|
screen->ChatIndex = ChatScreen_ClampIndex(defaultIndex);
|
||||||
ChatScreen_ResetChat(screen);
|
ChatScreen_ResetChat(screen);
|
||||||
}
|
}
|
||||||
} else if (key == Key_PageUp) {
|
} else if (key == Key_PageUp) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user