mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
cleanup code a bit
This commit is contained in:
parent
9473646252
commit
3cea320efc
@ -232,9 +232,6 @@ namespace ClassicalSharp {
|
||||
|
||||
static StringBuffer buffer = new StringBuffer(64);
|
||||
static string DefaultName(BlockID block) {
|
||||
#if USE16_BIT
|
||||
if (block >= 256) return "ID " + block;
|
||||
#endif
|
||||
if (block >= Block.CpeCount) return "Invalid";
|
||||
|
||||
// Find start and end of this particular block name
|
||||
@ -353,7 +350,6 @@ namespace ClassicalSharp {
|
||||
f |= occludedY && (bothLiquid || (oMin.Y == 0 && bMax.Y == 1)) ? (1 << Side.Top) : 0;
|
||||
BlockInfo.hidden[(block * Count) | other] = (byte)f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static bool IsHidden(BlockID block, BlockID other) {
|
||||
|
@ -18,18 +18,10 @@ Size2D Size2D_Make(Int32 width, Int32 height) {
|
||||
Size2D s; s.Width = width; s.Height = height; return s;
|
||||
}
|
||||
|
||||
bool Size2D_Equals(Size2D a, Size2D b) {
|
||||
return a.Width == b.Width && a.Height == b.Height;
|
||||
}
|
||||
|
||||
Point2D Point2D_Make(Int32 x, Int32 y) {
|
||||
Point2D p; p.X = x; p.Y = y; return p;
|
||||
}
|
||||
|
||||
bool Point2D_Equals(Point2D a, Point2D b) {
|
||||
return a.X == b.X && a.Y == b.Y;
|
||||
}
|
||||
|
||||
TextureRec TextureRec_FromRegion(Real32 u, Real32 v, Real32 uWidth, Real32 vHeight) {
|
||||
TextureRec rec;
|
||||
rec.U1 = u; rec.V1 = v;
|
||||
|
@ -22,10 +22,7 @@ bool Rectangle2D_Contains(Rectangle2D a, Int32 x, Int32 y);
|
||||
bool Rectangle2D_Equals(Rectangle2D a, Rectangle2D b);
|
||||
|
||||
Size2D Size2D_Make(Int32 width, Int32 height);
|
||||
bool Size2D_Equals(Size2D a, Size2D b);
|
||||
|
||||
Point2D Point2D_Make(Int32 x, Int32 y);
|
||||
bool Point2D_Equals(Point2D a, Point2D b);
|
||||
|
||||
/* Stores the four texture coordinates that describe a textured quad. */
|
||||
typedef struct TextureRec_ { Real32 U1, V1, U2, V2; } TextureRec;
|
||||
|
@ -85,10 +85,8 @@
|
||||
|
||||
#if USE16_BIT
|
||||
#define BLOCK_MAX_DEFINED 0x3FF
|
||||
#define BLOCK_SHIFT 10
|
||||
#else
|
||||
#define BLOCK_MAX_DEFINED 0xFF
|
||||
#define BLOCK_SHIFT 8
|
||||
#endif
|
||||
|
||||
#define BLOCK_RAW_NAMES "Air Stone Grass Dirt Cobblestone Wood Sapling Bedrock Water StillWater Lava"\
|
||||
|
@ -153,7 +153,7 @@ void Builder_Stretch(Int32 x1, Int32 y1, Int32 z1) {
|
||||
|
||||
Builder_X = x; Builder_Y = y; Builder_Z = z;
|
||||
Builder_FullBright = Block_FullBright[b];
|
||||
Int32 tileIdx = b << BLOCK_SHIFT;
|
||||
UInt32 tileIdx = b * BLOCK_COUNT;
|
||||
/* All of these function calls are inlined as they can be called tens of millions to hundreds of millions of times. */
|
||||
|
||||
if (Builder_Counts[index] == 0 ||
|
||||
|
@ -58,7 +58,7 @@ void PerspectiveCamera_RegrabMouse(void) {
|
||||
Int32 cenX = topLeft.X + Game_Width / 2;
|
||||
Int32 cenY = topLeft.Y + Game_Height / 2;
|
||||
|
||||
Point2D point = Point2D_Make(cenX, cenY);
|
||||
Point2D point = { cenX, cenY };
|
||||
Window_SetDesktopCursorPos(point);
|
||||
previous = point;
|
||||
delta = Point2D_Empty;
|
||||
|
@ -482,7 +482,7 @@ void TeleportCommand_Execute(STRING_PURE String* args, UInt32 argsCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 v = VECTOR3_CONST(x, y, z);
|
||||
Vector3 v = { x, y, z };
|
||||
LocationUpdate update; LocationUpdate_MakePos(&update, v, false);
|
||||
Entity* entity = &LocalPlayer_Instance.Base.Base;
|
||||
entity->VTABLE->SetLocation(entity, &update, false);
|
||||
|
@ -130,7 +130,7 @@ Int32 Drawer2D_FontHeight(FontDesc* font, bool useShadow) {
|
||||
|
||||
Texture Drawer2D_MakeTextTexture(DrawTextArgs* args, Int32 windowX, Int32 windowY) {
|
||||
Size2D size = Drawer2D_MeasureText(args);
|
||||
if (Size2D_Equals(size, Size2D_Empty)) {
|
||||
if (size.Width == 0.0f && size.Height == 0.0f) {
|
||||
return Texture_FromOrigin(NULL, windowX, windowY, 0, 0, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
@ -343,7 +343,7 @@ void Drawer2D_DrawBitmapText(DrawTextArgs* args, Int32 x, Int32 y) {
|
||||
Size2D Drawer2D_MeasureBitmapText(DrawTextArgs* args) {
|
||||
if (Drawer2D_IsEmptyText(&args->Text)) return Size2D_Empty;
|
||||
Int32 textHeight = Drawer2D_AdjTextSize(args->Font.Size);
|
||||
Size2D total = Size2D_Make(0, Drawer2D_CellSize(textHeight));
|
||||
Size2D total = { 0, Drawer2D_CellSize(textHeight) };
|
||||
Int32 point = Math_Floor(args->Font.Size);
|
||||
|
||||
String text = args->Text;
|
||||
|
@ -534,7 +534,7 @@ void ShadowComponent_CalcAlpha(Real32 playerY, ShadowData* data) {
|
||||
|
||||
bool ShadowComponent_GetBlocks(Entity* entity, Vector3I* coords, Real32 x, Real32 z, Int32 posY, ShadowData* data) {
|
||||
Int32 blockX = Math_Floor(x), blockZ = Math_Floor(z);
|
||||
Vector3I p = VECTOR3I_CONST(blockX, 0, blockZ);
|
||||
Vector3I p = { blockX, 0, blockZ };
|
||||
|
||||
/* Check we have not processed this particular block already */
|
||||
UInt32 i, posCount = 0;
|
||||
|
@ -75,8 +75,8 @@ void HeldBlockRenderer_ResetHeldState(void) {
|
||||
|
||||
void HeldBlockRenderer_SetBaseOffset(void) {
|
||||
bool sprite = Block_Draw[held_block] == DRAW_SPRITE;
|
||||
Vector3 normalOffset = VECTOR3_CONST(0.56f, -0.72f, -0.72f);
|
||||
Vector3 spriteOffset = VECTOR3_CONST(0.46f, -0.52f, -0.72f);
|
||||
Vector3 normalOffset = { 0.56f, -0.72f, -0.72f };
|
||||
Vector3 spriteOffset = { 0.46f, -0.52f, -0.72f };
|
||||
Vector3 offset = sprite ? spriteOffset : normalOffset;
|
||||
|
||||
Vector3_Add(&held_entity.Position, &held_entity.Position, &offset);
|
||||
|
@ -17,7 +17,7 @@ void PickedPos_TestAxis(PickedPos* pos, Real32 dAxis, Face fAxis) {
|
||||
}
|
||||
|
||||
void PickedPos_SetAsValid(PickedPos* pos, RayTracer* t, Vector3 intersect) {
|
||||
Vector3I blockPos = VECTOR3I_CONST(t->X, t->Y, t->Z);
|
||||
Vector3I blockPos = { t->X, t->Y, t->Z };
|
||||
pos->Valid = true;
|
||||
pos->BlockPos = blockPos;
|
||||
pos->Block = t->Block;
|
||||
@ -44,7 +44,7 @@ void PickedPos_SetAsValid(PickedPos* pos, RayTracer* t, Vector3 intersect) {
|
||||
}
|
||||
|
||||
void PickedPos_SetAsInvalid(PickedPos* pos) {
|
||||
Vector3I blockPos = VECTOR3I_CONST(-1, -1, -1);
|
||||
Vector3I blockPos = { -1, -1, -1 };
|
||||
pos->Valid = false;
|
||||
pos->BlockPos = blockPos;
|
||||
pos->Block = BLOCK_AIR;
|
||||
|
@ -21,7 +21,6 @@ Real32 Vector3_Length(Vector3* v);
|
||||
Real32 Vector3_LengthSquared(Vector3* v);
|
||||
|
||||
#define VECTOR3_CONST(x, y, z) { x, y, z };
|
||||
#define VECTOR3I_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)
|
||||
#define Vector3_UnitZ VECTOR3_CONST(0.0f, 0.0f, 1.0f)
|
||||
|
@ -1188,7 +1188,7 @@ void InputWidget_RemakeTexture(GuiElement* elem) {
|
||||
totalHeight += widget->LineSizes[i].Height;
|
||||
maxWidth = max(maxWidth, widget->LineSizes[i].Width);
|
||||
}
|
||||
Size2D size = Size2D_Make(maxWidth, totalHeight);
|
||||
Size2D size = { maxWidth, totalHeight };
|
||||
widget->CaretAccumulator = 0;
|
||||
|
||||
Int32 realHeight = 0;
|
||||
|
@ -208,14 +208,14 @@ LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPAR
|
||||
case WM_WINDOWPOSCHANGED:
|
||||
pos = (WINDOWPOS*)lParam;
|
||||
if (pos->hwnd == win_Handle) {
|
||||
Point2D new_location = Point2D_Make(pos->x, pos->y);
|
||||
if (!Point2D_Equals(Window_GetLocation(), new_location)) {
|
||||
Point2D loc = Window_GetLocation();
|
||||
if (loc.X != pos->x || loc.Y != pos->y) {
|
||||
win_Bounds.X = pos->x; win_Bounds.Y = pos->y;
|
||||
Event_RaiseVoid(&WindowEvents_Moved);
|
||||
}
|
||||
|
||||
Size2D new_size = Size2D_Make(pos->cx, pos->cy);
|
||||
if (!Size2D_Equals(Window_GetSize(), new_size)) {
|
||||
Size2D size = Window_GetSize();
|
||||
if (size.Width != pos->cx || size.Height != pos->cy) {
|
||||
win_Bounds.Width = pos->cx; win_Bounds.Height = pos->cy;
|
||||
|
||||
RECT rect;
|
||||
@ -539,7 +539,7 @@ void Window_SetSize(Size2D size) {
|
||||
|
||||
Rectangle2D Window_GetClientRectangle(void) { return win_ClientRect; }
|
||||
void Window_SetClientRectangle(Rectangle2D rect) {
|
||||
Size2D size = Size2D_Make(rect.Width, rect.Height);
|
||||
Size2D size = { rect.Width, rect.Height };
|
||||
Window_SetClientSize(size);
|
||||
}
|
||||
|
||||
@ -659,8 +659,8 @@ Point2D Window_PointToScreen(Point2D p) {
|
||||
ErrorHandler_Fail("PointToScreen NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
MSG msg;
|
||||
void Window_ProcessEvents(void) {
|
||||
MSG msg;
|
||||
while (PeekMessageA(&msg, NULL, 0, 0, 1)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageA(&msg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user