mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -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();
|
||||
altText.SetActive(false);
|
||||
|
||||
// Do we need to move all chat down?
|
||||
int resetIndex = game.Chat.Log.Count - chatLines;
|
||||
if (chatIndex != resetIndex) {
|
||||
chatIndex = ClampIndex(resetIndex);
|
||||
// Reset chat when user has scrolled up in chat history
|
||||
int defaultIndex = game.Chat.Log.Count - chatLines;
|
||||
if (chatIndex != defaultIndex) {
|
||||
chatIndex = ClampIndex(defaultIndex);
|
||||
ResetChat();
|
||||
}
|
||||
} 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) {
|
||||
entity->ModelScale = Vector3_Create1(1.0f);
|
||||
entity->ModelBlock = BLOCK_AIR;
|
||||
String entModel = String_InitAndClearArray(entity->ModelNameRaw);
|
||||
|
||||
Int32 sep = String_IndexOf(model, '|', 0);
|
||||
String name, scale;
|
||||
@ -141,20 +140,19 @@ void Entity_SetModel(Entity* entity, STRING_PURE String* model) {
|
||||
|
||||
/* 'giant' model kept for backwards compatibility */
|
||||
if (String_CaselessEqualsConst(model, "giant")) {
|
||||
String_AppendConst(&entModel, "humanoid");
|
||||
name = String_FromReadonly("humanoid");
|
||||
entity->ModelScale = Vector3_Create1(2.0f);
|
||||
} else if (Convert_TryParseUInt8(model, &entity->ModelBlock)) {
|
||||
String_AppendConst(&entModel, "block");
|
||||
} else {
|
||||
String_AppendString(&entModel, &name);
|
||||
name = String_FromReadonly("block");
|
||||
}
|
||||
|
||||
entity->Model = ModelCache_Get(&entModel);
|
||||
entity->Model = ModelCache_Get(&name);
|
||||
Entity_ParseScale(entity, scale);
|
||||
entity->MobTextureId = NULL;
|
||||
|
||||
entity->Model->RecalcProperties(entity);
|
||||
Entity_UpdateModelBounds(entity);
|
||||
entity->ModelIsSheepNoFur = String_CaselessEqualsConst(&name, "sheep_nofur");
|
||||
}
|
||||
|
||||
void Entity_UpdateModelBounds(Entity* entity) {
|
||||
|
@ -73,8 +73,8 @@ typedef struct Entity_ {
|
||||
Vector3 Velocity, OldVelocity;
|
||||
|
||||
IModel* Model;
|
||||
UInt8 ModelNameRaw[String_BufferSize(ENTITY_MAX_MODEL_LENGTH)];
|
||||
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;
|
||||
Vector3 ModelScale, Size;
|
||||
Real32 StepSize;
|
||||
|
@ -420,9 +420,7 @@ void SheepModel_DrawModel(Entity* entity) {
|
||||
IModel_DrawRotate(entity->Anim.LeftLegX, 0, 0, Sheep_RightLegBack, false);
|
||||
IModel_UpdateVB();
|
||||
|
||||
String entModel = String_FromRawArray(entity->ModelNameRaw);
|
||||
String sheep_nofur = String_FromConst("sheep_nofur");
|
||||
if (String_CaselessEquals(&entModel, &sheep_nofur)) return;
|
||||
if (entity->ModelIsSheepNoFur) return;
|
||||
Gfx_BindTexture(ModelCache_Textures[fur_Index].TexID);
|
||||
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);
|
||||
SpecialInputWidget_SetActive(&screen->AltText, false);
|
||||
|
||||
/* Do we need to move all chat down? */
|
||||
Int32 resetIndex = Chat_Log.Count - Game_ChatLines;
|
||||
if (screen->ChatIndex != resetIndex) {
|
||||
screen->ChatIndex = ChatScreen_ClampIndex(resetIndex);
|
||||
/* Reset chat when user has scrolled up in chat history */
|
||||
Int32 defaultIndex = Chat_Log.Count - Game_ChatLines;
|
||||
if (screen->ChatIndex != defaultIndex) {
|
||||
screen->ChatIndex = ChatScreen_ClampIndex(defaultIndex);
|
||||
ChatScreen_ResetChat(screen);
|
||||
}
|
||||
} else if (key == Key_PageUp) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user