diff --git a/src/Audio.c b/src/Audio.c index 86054416b..cdc7bbb9e 100644 --- a/src/Audio.c +++ b/src/Audio.c @@ -395,7 +395,7 @@ static void Music_RunLoop(void) { while (!music_pendingStop) { Int32 idx = Random_Range(&rnd, 0, count); - String filename = String_FromConst("hal2.ogg"); + String filename = StringsBuffer_UNSAFE_Get(&files, idx); String path = String_InitAndClearArray(pathBuffer); String_Format2(&path, "audio%r%s", &Directory_Separator, &filename); Platform_Log1("playing music file: %s", &filename); diff --git a/src/Block.c b/src/Block.c index 99b3d84aa..304f4ac7f 100644 --- a/src/Block.c +++ b/src/Block.c @@ -339,7 +339,7 @@ void Block_RecalculateBB(BlockID block) { maxY = Block_GetSpriteBB_MaxY(tileSize, x, y, bmp); } - Vector3 centre = VECTOR3_CONST(0.5f, 0.0f, 0.5f); + static Vector3 centre = { 0.5f, 0.0f, 0.5f }; Vector3 minRaw = Vector3_RotateY3(minX - 0.5f, minY, 0.0f, 45.0f * MATH_DEG2RAD); Vector3 maxRaw = Vector3_RotateY3(maxX - 0.5f, maxY, 0.0f, 45.0f * MATH_DEG2RAD); @@ -529,13 +529,13 @@ BlockID AutoRotate_RotateBlock(BlockID block) { Vector3I_ToVector3(&translated, &Game_SelectedPos.TranslatedPos); Vector3_Sub(&offset, &Game_SelectedPos.Intersect, &translated); - if (AR_EQ2(dir, 'n', 'w') || AR_EQ2(dir, 'n', 'e') || AR_EQ2(dir, 's', 'w') || AR_EQ2(dir, 's', 'e')) { + if (AR_EQ2(dir, 'n','w') || AR_EQ2(dir, 'n','e') || AR_EQ2(dir, 's','w') || AR_EQ2(dir, 's','e')) { return AutoRotate_RotateCorner(block, &baseName, offset); } else if (AR_EQ1(dir, 'u') || AR_EQ1(dir, 'd')) { return AutoRotate_RotateVertical(block, &baseName, offset); } else if (AR_EQ1(dir, 'n') || AR_EQ1(dir, 'w') || AR_EQ1(dir, 's') || AR_EQ1(dir, 'e')) { return AutoRotate_RotateDirection(block, &baseName, offset); - } else if (AR_EQ2(dir, 'u', 'd') || AR_EQ2(dir, 'w', 'e') || AR_EQ2(dir, 'n', 's')) { + } else if (AR_EQ2(dir, 'u','d') || AR_EQ2(dir, 'w','e') || AR_EQ2(dir, 'n','s')) { return AutoRotate_RotateOther(block, &baseName, offset); } return block; diff --git a/src/Drawer2D.c b/src/Drawer2D.c index 5fed083e0..a11161acb 100644 --- a/src/Drawer2D.c +++ b/src/Drawer2D.c @@ -403,7 +403,6 @@ struct Size2D Drawer2D_MeasureText(struct DrawTextArgs* args) { struct Size2D size = { 0, 0 }; while (i < value.length) { - UChar col = nextCol; i = Drawer2D_NextPart(i, &value, &args->Text, &nextCol); if (!args->Text.length) continue; diff --git a/src/ExtMath.c b/src/ExtMath.c index 35d922eed..a44114d05 100644 --- a/src/ExtMath.c +++ b/src/ExtMath.c @@ -49,9 +49,9 @@ Real32 Math_Lerp(Real32 a, Real32 b, Real32 t) { } Real32 Math_LerpAngle(Real32 leftAngle, Real32 rightAngle, Real32 t) { - /* we have to cheat a bit for angles here. */ - /* Consider 350* --> 0*, we only want to travel 10*, */ - /* but without adjusting for this case, we would interpolate back the whole 350* degrees.*/ + /* We have to cheat a bit for angles here */ + /* Consider 350* --> 0*, we only want to travel 10* */ + /* But without adjusting for this case, we would interpolate back the whole 350* degrees */ bool invertLeft = leftAngle > 270.0f && rightAngle < 90.0f; bool invertRight = rightAngle > 270.0f && leftAngle < 90.0f; if (invertLeft) leftAngle = leftAngle - 360.0f; diff --git a/src/Game.c b/src/Game.c index 497581413..81a6720a6 100644 --- a/src/Game.c +++ b/src/Game.c @@ -501,7 +501,7 @@ void Game_Load(void) { } Game_InitScheduledTasks(); - /* TODO: plugin dll support * / + /* TODO: plugin dll support */ /* if (nonLoaded != null) { for (int i = 0; i < nonLoaded.Count; i++) { Overlay warning = new PluginOverlay(this, nonLoaded[i]); diff --git a/src/HeldBlockRenderer.c b/src/HeldBlockRenderer.c index 481038dcd..8bedde37f 100644 --- a/src/HeldBlockRenderer.c +++ b/src/HeldBlockRenderer.c @@ -51,7 +51,7 @@ static void HeldBlockRenderer_RenderModel(void) { static void HeldBlockRenderer_SetMatrix(void) { struct Entity* player = &LocalPlayer_Instance.Base; - Vector3 eye = VECTOR3_CONST(0.0f, Entity_GetEyeHeight(player), 0.0f); + Vector3 eye = { 0, Entity_GetEyeHeight(player), 0 }; struct Matrix m, lookAt; Matrix_Translate(&lookAt, -eye.X, -eye.Y, -eye.Z); @@ -62,8 +62,8 @@ static void HeldBlockRenderer_SetMatrix(void) { static void HeldBlockRenderer_ResetHeldState(void) { /* Based off details from http://pastebin.com/KFV0HkmD (Thanks goodlyay!) */ struct Entity* player = &LocalPlayer_Instance.Base; - Vector3 eyePos = VECTOR3_CONST(0.0f, Entity_GetEyeHeight(player), 0.0f); - held_entity.Position = eyePos; + Vector3 eye = { 0, Entity_GetEyeHeight(player), 0 }; + held_entity.Position = eye; held_entity.Position.X -= Camera_BobbingHor; held_entity.Position.Y -= Camera_BobbingVer; diff --git a/src/IModel.c b/src/IModel.c index 77a05edc8..9f843f249 100644 --- a/src/IModel.c +++ b/src/IModel.c @@ -332,33 +332,33 @@ void BoxDesc_BuildRotatedBox(struct ModelPart* part, struct BoxDesc* desc) { void BoxDesc_XQuad(struct IModel* m, Int32 texX, Int32 texY, Int32 texWidth, Int32 texHeight, Real32 z1, Real32 z2, Real32 y1, Real32 y2, Real32 x, bool swapU) { - Int32 u1 = texX, u2 = texX + texWidth | UV_MAX; + Int32 u1 = texX, u2 = (texX + texWidth) | UV_MAX; if (swapU) { Int32 tmp = u1; u1 = u2; u2 = tmp; } - ModelVertex_Init(&m->vertices[m->index], x, y1, z1, u1, texY + texHeight | UV_MAX); m->index++; + ModelVertex_Init(&m->vertices[m->index], x, y1, z1, u1, (texY + texHeight) | UV_MAX); m->index++; ModelVertex_Init(&m->vertices[m->index], x, y2, z1, u1, texY); m->index++; ModelVertex_Init(&m->vertices[m->index], x, y2, z2, u2, texY); m->index++; - ModelVertex_Init(&m->vertices[m->index], x, y1, z2, u2, texY + texHeight | UV_MAX); m->index++; + ModelVertex_Init(&m->vertices[m->index], x, y1, z2, u2, (texY + texHeight) | UV_MAX); m->index++; } void BoxDesc_YQuad(struct IModel* m, Int32 texX, Int32 texY, Int32 texWidth, Int32 texHeight, Real32 x1, Real32 x2, Real32 z1, Real32 z2, Real32 y, bool swapU) { - Int32 u1 = texX, u2 = texX + texWidth | UV_MAX; + Int32 u1 = texX, u2 = (texX + texWidth) | UV_MAX; if (swapU) { Int32 tmp = u1; u1 = u2; u2 = tmp; } - ModelVertex_Init(&m->vertices[m->index], x1, y, z2, u1, texY + texHeight | UV_MAX); m->index++; + ModelVertex_Init(&m->vertices[m->index], x1, y, z2, u1, (texY + texHeight) | UV_MAX); m->index++; ModelVertex_Init(&m->vertices[m->index], x1, y, z1, u1, texY); m->index++; ModelVertex_Init(&m->vertices[m->index], x2, y, z1, u2, texY); m->index++; - ModelVertex_Init(&m->vertices[m->index], x2, y, z2, u2, texY + texHeight | UV_MAX); m->index++; + ModelVertex_Init(&m->vertices[m->index], x2, y, z2, u2, (texY + texHeight) | UV_MAX); m->index++; } void BoxDesc_ZQuad(struct IModel* m, Int32 texX, Int32 texY, Int32 texWidth, Int32 texHeight, Real32 x1, Real32 x2, Real32 y1, Real32 y2, Real32 z, bool swapU) { - Int32 u1 = texX, u2 = texX + texWidth | UV_MAX; + Int32 u1 = texX, u2 = (texX + texWidth) | UV_MAX; if (swapU) { Int32 tmp = u1; u1 = u2; u2 = tmp; } - ModelVertex_Init(&m->vertices[m->index], x1, y1, z, u1, texY + texHeight | UV_MAX); m->index++; + ModelVertex_Init(&m->vertices[m->index], x1, y1, z, u1, (texY + texHeight) | UV_MAX); m->index++; ModelVertex_Init(&m->vertices[m->index], x1, y2, z, u1, texY); m->index++; ModelVertex_Init(&m->vertices[m->index], x2, y2, z, u2, texY); m->index++; - ModelVertex_Init(&m->vertices[m->index], x2, y1, z, u2, texY + texHeight | UV_MAX); m->index++; + ModelVertex_Init(&m->vertices[m->index], x2, y1, z, u2, (texY + texHeight) | UV_MAX); m->index++; } diff --git a/src/Menus.c b/src/Menus.c index 093bdb425..fef465040 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -2602,13 +2602,6 @@ static void GuiOptionsScreen_SetUseFont(STRING_PURE String* v) { Menu_HandleFontChange((struct GuiElem*)&MenuOptionsScreen_Instance); } -static void GuiOptionsScreen_GetFont(STRING_TRANSIENT String* v) { String_AppendString(v, &Game_FontName); } -static void GuiOptionsScreen_SetFont(STRING_PURE String* v) { - String_Set(&Game_FontName, v); - Options_Set(OPT_FONT_NAME, v); - Menu_HandleFontChange((struct GuiElem*)&MenuOptionsScreen_Instance); -} - static void GuiOptionsScreen_ContextRecreated(void* obj) { struct MenuOptionsScreen* screen = (struct MenuOptionsScreen*)obj; struct Widget** widgets = screen->Widgets; diff --git a/src/ModelCache.c b/src/ModelCache.c index b4f9c8e6b..c422fc610 100644 --- a/src/ModelCache.c +++ b/src/ModelCache.c @@ -1110,8 +1110,8 @@ static Real32 BlockModel_GetEyeY(struct Entity* entity) { static void BlockModel_GetCollisionSize(Vector3* size) { Vector3_Sub(size, &BlockModel_maxBB, &BlockModel_minBB); /* to fit slightly inside */ - Vector3 sizeShrink = VECTOR3_CONST1(0.75f / 16.0f); - Vector3_SubBy(size, &sizeShrink); + static Vector3 shrink = { 0.75f/16.0f, 0.75f/16.0f, 0.75f/16.0f }; + Vector3_SubBy(size, &shrink); } static void BlockModel_GetPickingBounds(struct AABB* bb) { diff --git a/src/PacketHandlers.c b/src/PacketHandlers.c index e253e490b..b3a01400b 100644 --- a/src/PacketHandlers.c +++ b/src/PacketHandlers.c @@ -618,7 +618,7 @@ static void Classic_ReadAbsoluteLocation(UInt8* data, EntityID id, bool interpol y -= 51; /* Convert to feet position */ if (id == ENTITIES_SELF_ID) y += 22; - Vector3 pos = VECTOR3_CONST(x / 32.0f, y / 32.0f, z / 32.0f); + Vector3 pos = { x/32.0f, y/32.0f, z/32.0f }; Real32 rotY = Math_Packed2Deg(*data++); Real32 headX = Math_Packed2Deg(*data++); diff --git a/src/Picking.c b/src/Picking.c index 4904e6660..77bdff4a9 100644 --- a/src/Picking.c +++ b/src/Picking.c @@ -199,7 +199,7 @@ static bool Picking_ClipBlock(struct PickedPos* pos) { return true; } -static Vector3 picking_adjust = VECTOR3_CONST1(0.1f); +static Vector3 picking_adjust = { 0.1f, 0.1f, 0.1f }; static bool Picking_ClipCamera(struct PickedPos* pos) { if (Block_Draw[tracer.Block] == DRAW_GAS || Block_Collide[tracer.Block] != COLLIDE_SOLID) return false; Real32 t0, t1; diff --git a/src/Program.c b/src/Program.c index 64ee0c5aa..0b4008618 100644 --- a/src/Program.c +++ b/src/Program.c @@ -112,18 +112,18 @@ int main(void) { String bits[4]; UInt32 bitsCount = Array_Elems(bits); String_UNSAFE_Split(&args[2], '.', bits, &bitsCount); if (bitsCount != Array_Elems(bits)) { - Platform_LogConst("Invalid IP"); return; + Platform_LogConst("Invalid IP"); return 1; } UInt8 ipTmp; if (!Convert_TryParseUInt8(&bits[0], &ipTmp) || !Convert_TryParseUInt8(&bits[1], &ipTmp) || !Convert_TryParseUInt8(&bits[2], &ipTmp) || !Convert_TryParseUInt8(&bits[3], &ipTmp)) { - Platform_LogConst("Invalid IP"); return; + Platform_LogConst("Invalid IP"); return 1; } UInt16 portTmp; if (!Convert_TryParseUInt16(&args[3], &portTmp)) { - Platform_LogConst("Invalid port"); return; + Platform_LogConst("Invalid port"); return 1; } Game_Port = portTmp; } diff --git a/src/Vectors.c b/src/Vectors.c index 33010fcda..46a84ea4a 100644 --- a/src/Vectors.c +++ b/src/Vectors.c @@ -15,7 +15,7 @@ Vector3I Vector3I_MaxValue(void) { } Vector3 Vector3_BigPos(void) { - Vector3 v = VECTOR3_CONST1(1e25f); return v; + Vector3 v = { 1e25f, 1e25f, 1e25f }; return v; } Real32 Vector3_LengthSquared(Vector3* v) { diff --git a/src/Vectors.h b/src/Vectors.h index b907e3406..d1d30467b 100644 --- a/src/Vectors.h +++ b/src/Vectors.h @@ -19,7 +19,6 @@ Vector3I Vector3I_MaxValue(void); Vector3 Vector3_BigPos(void); Real32 Vector3_LengthSquared(Vector3* v); -#define VECTOR3_CONST1(val) { val, val, val }; #define VECTOR3_CONST(x, y, z) { x, y, z }; #define Vector3_UnitX VECTOR3_CONST(1.0f, 0.0f, 0.0f) #define Vector3_UnitY VECTOR3_CONST(0.0f, 1.0f, 0.0f) @@ -40,7 +39,6 @@ void Vector3_Negate(Vector3* result, Vector3* a); #define Vector3_Mul3By(dst, value) Vector3_Mul3(dst, dst, value) void Vector3_Lerp(Vector3* result, Vector3* a, Vector3* b, Real32 blend); -Real32 Vector3_Dot(Vector3* left, Vector3* right); void Vector3_Normalize(Vector3* result, Vector3* a); void Vector3_Transform(Vector3* result, Vector3* a, struct Matrix* mat);