From d90b06e6a8f3cded57c1cdb84a70bf32d0064f58 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 24 Jul 2020 19:36:03 +1000 Subject: [PATCH] minor code cleanup --- src/Builder.c | 1 - src/Gui.h | 2 +- src/Model.h | 3 --- src/Particle.c | 2 ++ src/Protocol.c | 23 ++++++++--------------- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/Builder.c b/src/Builder.c index 5f26898b6..8d943b0a3 100644 --- a/src/Builder.c +++ b/src/Builder.c @@ -8,7 +8,6 @@ #include "Graphics.h" #include "Drawer.h" #include "ExtMath.h" -#include "BlockID.h" #include "Block.h" #include "PackedCol.h" #include "TexturePack.h" diff --git a/src/Gui.h b/src/Gui.h index eeb428e35..3895f5816 100644 --- a/src/Gui.h +++ b/src/Gui.h @@ -178,7 +178,7 @@ CC_API void Gui_Remove(struct Screen* screen); CC_API void Gui_Add(struct Screen* screen, int priority); /* Returns highest priority screen that has grabbed input. */ -struct Screen* Gui_GetInputGrab(void); +CC_API struct Screen* Gui_GetInputGrab(void); /* Returns highest priority screen that blocks world rendering. */ struct Screen* Gui_GetBlocksWorld(void); /* Returns highest priority screen that is closable. */ diff --git a/src/Model.h b/src/Model.h index ba87fa6d2..a2fafcfb4 100644 --- a/src/Model.h +++ b/src/Model.h @@ -83,9 +83,6 @@ struct Model { float maxScale, shadowScale, nameScale; struct Model* next; }; -#if 0 -public CustomModel[] CustomModels = new CustomModel[256]; -#endif /* Shared data for models. */ CC_VAR extern struct _ModelsData { diff --git a/src/Particle.c b/src/Particle.c index f7a96ebde..a91bcdf4f 100644 --- a/src/Particle.c +++ b/src/Particle.c @@ -536,6 +536,8 @@ void Particles_CustomEffect(int effectID, float x, float y, float z, float origi offset.Z = Random_Float(&rnd) - 0.5f; Vec3_Normalize(&offset, &offset); + /* See https://karthikkaranth.me/blog/generating-random-points-in-a-sphere/ */ + /* 'Using normally distributed random numbers' */ d = Random_Float(&rnd); d = Math_Exp(Math_Log(d) / 3.0); /* d^1/3 for better distribution */ d *= e->spread; diff --git a/src/Protocol.c b/src/Protocol.c index c32313637..b561c0ec7 100644 --- a/src/Protocol.c +++ b/src/Protocol.c @@ -1466,22 +1466,15 @@ static void CPE_DefineModel(cc_uint8* data) { static void CPE_DefineModelPart(cc_uint8* data) { /* 103 = 1 + 3*4 + 3*4 + 6*(2*2 + 2*2) + 3*4 + 3*4 + 1 + 4 + 1 */ - cc_uint8 modelId = *data++; - struct CustomModel* customModel = &custom_models[modelId]; + cc_uint8 id = *data++; + struct CustomModel* m = &custom_models[id]; struct CustomModelPart* part; cc_uint8 flags; int i; - if ( - modelId >= MAX_CUSTOM_MODELS || - !customModel->defined || - customModel->curPartIndex >= customModel->numParts - ) { - return; - } - - part = &customModel->parts[customModel->curPartIndex]; - customModel->curPartIndex++; + if (id >= MAX_CUSTOM_MODELS || !m->defined || m->curPartIndex >= m->numParts) return; + part = &m->parts[m->curPartIndex]; + m->curPartIndex++; /* read min, max vec3 coords */ part->min.X = GetFloat(data); @@ -1550,12 +1543,12 @@ static void CPE_DefineModelPart(cc_uint8* data) { /* read bool flags */ flags = *data++; - part->fullbright = (flags >> 0) & 1; + part->fullbright = (flags >> 0) & 1; part->firstPersonArm = (flags >> 1) & 1; - if (customModel->curPartIndex == customModel->numParts) { + if (m->curPartIndex == m->numParts) { /* we're the last part, so register our model */ - CustomModel_Register(customModel); + CustomModel_Register(m); } }