mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
C client: shrink by 5kb
This commit is contained in:
parent
63371827b6
commit
2520e649c0
@ -535,7 +535,6 @@ static void CuboidCommand_Make(struct ChatCommand* cmd) {
|
||||
*------------------------------------------------------TeleportCommand----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void TeleportCommand_Execute(STRING_PURE String* args, Int32 argsCount) {
|
||||
ErrorHandler_Fail("DED");
|
||||
if (argsCount != 4) {
|
||||
Chat_AddRaw("&e/client teleport: &cYou didn't specify X, Y and Z coordinates.");
|
||||
} else {
|
||||
|
@ -107,7 +107,9 @@ static void ErrorHandler_Backtrace(STRING_TRANSIENT String* str, void* ctx) {
|
||||
Int32 number = i + 1;
|
||||
UInt64 addr = (UInt64)pointers[i].Instruction;
|
||||
|
||||
/* TODO: Log ESP and EBP here too */
|
||||
/* TODO: SymGetLineFromAddr64 as well? */
|
||||
/* TODO: Log module here too */
|
||||
if (SymGetSymFromAddr64(process, addr, NULL, &sym.Symbol)) {
|
||||
String_Format3(str, "%i) 0x%x - %c\r\n", &number, &addr, sym.Symbol.Name);
|
||||
} else {
|
||||
|
@ -6,12 +6,11 @@
|
||||
#include "Game.h"
|
||||
#include "Event.h"
|
||||
#include "Picking.h"
|
||||
#include "Funcs.h"
|
||||
|
||||
GfxResourceID pickedPos_vb;
|
||||
PackedCol pickedPos_col = PACKEDCOL_CONST(0, 0, 0, 102);
|
||||
#define pickedPos_numVertices (16 * 6)
|
||||
VertexP3fC4b pickedPos_vertices[pickedPos_numVertices];
|
||||
VertexP3fC4b* pickedPos_ptr;
|
||||
|
||||
static void PickedPosRenderer_ContextLost(void* obj) {
|
||||
Gfx_DeleteVb(&pickedPos_vb);
|
||||
@ -45,32 +44,7 @@ void PickedPosRenderer_Render(Real64 delta) {
|
||||
Gfx_SetAlphaBlending(false);
|
||||
}
|
||||
|
||||
static void PickedPosRenderer_XQuad(Real32 x, Real32 z1, Real32 y1, Real32 z2, Real32 y2) {
|
||||
VertexP3fC4b v; v.X = x; v.Col = pickedPos_col;
|
||||
v.Y = y1; v.Z = z1; *pickedPos_ptr++ = v;
|
||||
v.Y = y2; *pickedPos_ptr++ = v;
|
||||
v.Z = z2; *pickedPos_ptr++ = v;
|
||||
v.Y = y1; *pickedPos_ptr++ = v;
|
||||
}
|
||||
|
||||
static void PickedPosRenderer_YQuad(Real32 y, Real32 x1, Real32 z1, Real32 x2, Real32 z2) {
|
||||
VertexP3fC4b v; v.Y = y; v.Col = pickedPos_col;
|
||||
v.X = x1; v.Z = z1; *pickedPos_ptr++ = v;
|
||||
v.Z = z2; *pickedPos_ptr++ = v;
|
||||
v.X = x2; *pickedPos_ptr++ = v;
|
||||
v.Z = z1; *pickedPos_ptr++ = v;
|
||||
}
|
||||
|
||||
static void PickedPosRenderer_ZQuad(Real32 z, Real32 x1, Real32 y1, Real32 x2, Real32 y2) {
|
||||
VertexP3fC4b v; v.Z = z; v.Col = pickedPos_col;
|
||||
v.X = x1; v.Y = y1; *pickedPos_ptr++ = v;
|
||||
v.Y = y2; *pickedPos_ptr++ = v;
|
||||
v.X = x2; *pickedPos_ptr++ = v;
|
||||
v.Y = y1; *pickedPos_ptr++ = v;
|
||||
}
|
||||
|
||||
void PickedPosRenderer_Update(struct PickedPos* selected) {
|
||||
pickedPos_ptr = pickedPos_vertices;
|
||||
Vector3 delta;
|
||||
Vector3_Sub(&delta, &Game_CurrentCameraPos, &selected->Min);
|
||||
Real32 dist = Vector3_LengthSquared(&delta);
|
||||
@ -79,10 +53,6 @@ void PickedPosRenderer_Update(struct PickedPos* selected) {
|
||||
if (dist < 4.0f * 4.0f) offset = 0.00625f;
|
||||
if (dist < 2.0f * 2.0f) offset = 0.00500f;
|
||||
|
||||
Vector3 p1, p2;
|
||||
Vector3_Add1(&p1, &selected->Min, -offset);
|
||||
Vector3_Add1(&p2, &selected->Max, offset);
|
||||
|
||||
Real32 size = 1.0f / 16.0f;
|
||||
if (dist < 32.0f * 32.0f) size = 1.0f / 32.0f;
|
||||
if (dist < 16.0f * 16.0f) size = 1.0f / 64.0f;
|
||||
@ -90,41 +60,59 @@ void PickedPosRenderer_Update(struct PickedPos* selected) {
|
||||
if (dist < 4.0f * 4.0f) size = 1.0f / 128.0f;
|
||||
if (dist < 2.0f * 2.0f) size = 1.0f / 192.0f;
|
||||
|
||||
/* bottom face */
|
||||
PickedPosRenderer_YQuad(p1.Y, p1.X, p1.Z + size, p1.X + size, p2.Z - size);
|
||||
PickedPosRenderer_YQuad(p1.Y, p2.X, p1.Z + size, p2.X - size, p2.Z - size);
|
||||
PickedPosRenderer_YQuad(p1.Y, p1.X, p1.Z, p2.X, p1.Z + size);
|
||||
PickedPosRenderer_YQuad(p1.Y, p1.X, p2.Z, p2.X, p2.Z - size);
|
||||
/* How a face is laid out:
|
||||
#--#-------#--#<== OUTER_MAX (3)
|
||||
| | | |
|
||||
| #-------#<===== INNER_MAX (2)
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
(1) INNER_MIN =====>#-------# |
|
||||
| | | |
|
||||
(0) OUTER_MIN ==>#--#-------#--#
|
||||
|
||||
/* top face */
|
||||
PickedPosRenderer_YQuad(p2.Y, p1.X, p1.Z + size, p1.X + size, p2.Z - size);
|
||||
PickedPosRenderer_YQuad(p2.Y, p2.X, p1.Z + size, p2.X - size, p2.Z - size);
|
||||
PickedPosRenderer_YQuad(p2.Y, p1.X, p1.Z, p2.X, p1.Z + size);
|
||||
PickedPosRenderer_YQuad(p2.Y, p1.X, p2.Z, p2.X, p2.Z - size);
|
||||
- these are used to fake thick lines, by making the lines appear slightly inset
|
||||
- note: actual difference between inner and outer is much smaller then the diagram
|
||||
*/
|
||||
Vector3 coords[4];
|
||||
Vector3_Add1(&coords[0], &selected->Min, -offset);
|
||||
Vector3_Add1(&coords[1], &coords[0], size);
|
||||
Vector3_Add1(&coords[3], &selected->Max, offset);
|
||||
Vector3_Add1(&coords[2], &coords[3], -size);
|
||||
|
||||
/* left face */
|
||||
PickedPosRenderer_XQuad(p1.X, p1.Z, p1.Y + size, p1.Z + size, p2.Y - size);
|
||||
PickedPosRenderer_XQuad(p1.X, p2.Z, p1.Y + size, p2.Z - size, p2.Y - size);
|
||||
PickedPosRenderer_XQuad(p1.X, p1.Z, p1.Y, p2.Z, p1.Y + size);
|
||||
PickedPosRenderer_XQuad(p1.X, p1.Z, p2.Y, p2.Z, p2.Y - size);
|
||||
#define PickedPos_Y(y)\
|
||||
0,y,1, 0,y,2, 1,y,2, 1,y,1,\
|
||||
3,y,1, 3,y,2, 2,y,2, 2,y,1,\
|
||||
0,y,0, 0,y,1, 3,y,1, 3,y,0,\
|
||||
0,y,3, 0,y,2, 3,y,2, 3,y,3,
|
||||
|
||||
/* right face */
|
||||
PickedPosRenderer_XQuad(p2.X, p1.Z, p1.Y + size, p1.Z + size, p2.Y - size);
|
||||
PickedPosRenderer_XQuad(p2.X, p2.Z, p1.Y + size, p2.Z - size, p2.Y - size);
|
||||
PickedPosRenderer_XQuad(p2.X, p1.Z, p1.Y, p2.Z, p1.Y + size);
|
||||
PickedPosRenderer_XQuad(p2.X, p1.Z, p2.Y, p2.Z, p2.Y - size);
|
||||
#define PickedPos_X(x)\
|
||||
x,1,0, x,2,0, x,2,1, x,1,1,\
|
||||
x,1,3, x,2,3, x,2,2, x,1,2,\
|
||||
x,0,0, x,1,0, x,1,3, x,0,3,\
|
||||
x,3,0, x,2,0, x,2,3, x,3,3,
|
||||
|
||||
/* front face */
|
||||
PickedPosRenderer_ZQuad(p1.Z, p1.X, p1.Y + size, p1.X + size, p2.Y - size);
|
||||
PickedPosRenderer_ZQuad(p1.Z, p2.X, p1.Y + size, p2.X - size, p2.Y - size);
|
||||
PickedPosRenderer_ZQuad(p1.Z, p1.X, p1.Y, p2.X, p1.Y + size);
|
||||
PickedPosRenderer_ZQuad(p1.Z, p1.X, p2.Y, p2.X, p2.Y - size);
|
||||
#define PickedPos_Z(z)\
|
||||
0,1,z, 0,2,z, 1,2,z, 1,1,z,\
|
||||
3,1,z, 3,2,z, 2,2,z, 2,1,z,\
|
||||
0,0,z, 0,1,z, 3,1,z, 3,0,z,\
|
||||
0,3,z, 0,2,z, 3,2,z, 3,3,z,
|
||||
|
||||
/* back face */
|
||||
PickedPosRenderer_ZQuad(p2.Z, p1.X, p1.Y + size, p1.X + size, p2.Y - size);
|
||||
PickedPosRenderer_ZQuad(p2.Z, p2.X, p1.Y + size, p2.X - size, p2.Y - size);
|
||||
PickedPosRenderer_ZQuad(p2.Z, p1.X, p1.Y, p2.X, p1.Y + size);
|
||||
PickedPosRenderer_ZQuad(p2.Z, p1.X, p2.Y, p2.X, p2.Y - size);
|
||||
static UInt8 faces[288] = {
|
||||
PickedPos_Y(0) PickedPos_Y(3) /* YMin, YMax */
|
||||
PickedPos_X(0) PickedPos_X(3) /* XMin, XMax */
|
||||
PickedPos_Z(0) PickedPos_Z(3) /* ZMin, ZMax */
|
||||
};
|
||||
PackedCol col = PACKEDCOL_CONST(0, 0, 0, 102);
|
||||
VertexP3fC4b* ptr = pickedPos_vertices;
|
||||
Int32 i;
|
||||
|
||||
for (i = 0; i < Array_Elems(faces); i += 3, ptr++) {
|
||||
ptr->X = coords[faces[i + 0]].X;
|
||||
ptr->Y = coords[faces[i + 1]].Y;
|
||||
ptr->Z = coords[faces[i + 2]].Z;
|
||||
ptr->Col = col;
|
||||
}
|
||||
}
|
||||
|
||||
void PickedPosRenderer_MakeComponent(struct IGameComponent* comp) {
|
||||
|
@ -64,7 +64,7 @@ int main(void) {
|
||||
String title = String_FromConst(PROGRAM_APP_NAME);
|
||||
String rawArgs = Platform_GetCommandLineArgs();
|
||||
/* NOTE: Make sure to comment this out before pushing a commit */
|
||||
//rawArgs = String_FromReadonly("UnknownShadow200 fff 127.0.0.1 25566");
|
||||
rawArgs = String_FromReadonly("UnknownShadow200 fff 127.0.0.1 25565");
|
||||
|
||||
String args[5]; Int32 argsCount = Array_Elems(args);
|
||||
String_UNSAFE_Split(&rawArgs, ' ', args, &argsCount);
|
||||
|
@ -15,34 +15,48 @@ struct SelectionBox {
|
||||
|
||||
void SelectionBox_Render(struct SelectionBox* box, VertexP3fC4b** vertices, VertexP3fC4b** lineVertices) {
|
||||
Real32 offset = box->MinDist < 32.0f * 32.0f ? (1.0f / 32.0f) : (1.0f / 16.0f);
|
||||
Vector3 p1 = box->Min, p2 = box->Max;
|
||||
Vector3_Add1(&p1, &p1, -offset);
|
||||
Vector3_Add1(&p2, &p2, offset);
|
||||
Vector3 coords[2];
|
||||
Vector3_Add1(&coords[0], &box->Min, -offset);
|
||||
Vector3_Add1(&coords[1], &box->Max, offset);
|
||||
|
||||
Int32 i;
|
||||
VertexP3fC4b* ptr;
|
||||
PackedCol col = box->Col;
|
||||
|
||||
SelectionBox_HorQuad(vertices, col, p1.X, p1.Z, p2.X, p2.Z, p1.Y); /* bottom */
|
||||
SelectionBox_HorQuad(vertices, col, p1.X, p1.Z, p2.X, p2.Z, p2.Y); /* top */
|
||||
SelectionBox_VerQuad(vertices, col, p1.X, p1.Y, p1.Z, p2.X, p2.Y, p1.Z); /* sides */
|
||||
SelectionBox_VerQuad(vertices, col, p1.X, p1.Y, p2.Z, p2.X, p2.Y, p2.Z);
|
||||
SelectionBox_VerQuad(vertices, col, p1.X, p1.Y, p1.Z, p1.X, p2.Y, p2.Z);
|
||||
SelectionBox_VerQuad(vertices, col, p2.X, p1.Y, p1.Z, p2.X, p2.Y, p2.Z);
|
||||
#define SelectionBox_Y(y) 0,y,0, 0,y,1, 1,y,1, 1,y,0,
|
||||
#define SelectionBox_Z(z) 0,0,z, 0,1,z, 1,1,z, 1,0,z,
|
||||
#define SelectionBox_X(x) x,0,0, x,1,0, x,1,1, x,0,1,
|
||||
|
||||
static UInt8 faceIndices[72] = {
|
||||
SelectionBox_Y(0) SelectionBox_Y(1) /* YMin, YMax */
|
||||
SelectionBox_Z(0) SelectionBox_Z(1) /* ZMin, ZMax */
|
||||
SelectionBox_X(0) SelectionBox_X(1) /* XMin, XMax */
|
||||
};
|
||||
|
||||
ptr = *vertices;
|
||||
for (i = 0; i < Array_Elems(faceIndices); i += 3, ptr++) {
|
||||
ptr->X = coords[faceIndices[i + 0]].X;
|
||||
ptr->Y = coords[faceIndices[i + 1]].Y;
|
||||
ptr->Z = coords[faceIndices[i + 2]].Z;
|
||||
ptr->Col = col;
|
||||
}
|
||||
*vertices = ptr;
|
||||
|
||||
col.R = ~col.R; col.G = ~col.G; col.B = ~col.B;
|
||||
/* bottom face */
|
||||
SelectionBox_Line(lineVertices, col, p1.X, p1.Y, p1.Z, p2.X, p1.Y, p1.Z);
|
||||
SelectionBox_Line(lineVertices, col, p2.X, p1.Y, p1.Z, p2.X, p1.Y, p2.Z);
|
||||
SelectionBox_Line(lineVertices, col, p2.X, p1.Y, p2.Z, p1.X, p1.Y, p2.Z);
|
||||
SelectionBox_Line(lineVertices, col, p1.X, p1.Y, p2.Z, p1.X, p1.Y, p1.Z);
|
||||
/* top face */
|
||||
SelectionBox_Line(lineVertices, col, p1.X, p2.Y, p1.Z, p2.X, p2.Y, p1.Z);
|
||||
SelectionBox_Line(lineVertices, col, p2.X, p2.Y, p1.Z, p2.X, p2.Y, p2.Z);
|
||||
SelectionBox_Line(lineVertices, col, p2.X, p2.Y, p2.Z, p1.X, p2.Y, p2.Z);
|
||||
SelectionBox_Line(lineVertices, col, p1.X, p2.Y, p2.Z, p1.X, p2.Y, p1.Z);
|
||||
/* side faces */
|
||||
SelectionBox_Line(lineVertices, col, p1.X, p1.Y, p1.Z, p1.X, p2.Y, p1.Z);
|
||||
SelectionBox_Line(lineVertices, col, p2.X, p1.Y, p1.Z, p2.X, p2.Y, p1.Z);
|
||||
SelectionBox_Line(lineVertices, col, p2.X, p1.Y, p2.Z, p2.X, p2.Y, p2.Z);
|
||||
SelectionBox_Line(lineVertices, col, p1.X, p1.Y, p2.Z, p1.X, p2.Y, p2.Z);
|
||||
static UInt8 edgeIndices[72] = {
|
||||
0,0,0, 1,0,0, 1,0,0, 1,0,1, 1,0,1, 0,0,1, 0,0,1, 0,0,0, /* YMin */
|
||||
0,1,0, 1,1,0, 1,1,0, 1,1,1, 1,1,1, 0,1,1, 0,1,1, 0,1,0, /* YMax */
|
||||
0,0,0, 0,1,0, 1,0,0, 1,1,0, 1,0,1, 1,1,1, 0,0,1, 0,1,1, /* X/Z */
|
||||
};
|
||||
|
||||
ptr = *lineVertices;
|
||||
for (i = 0; i < Array_Elems(edgeIndices); i += 3, ptr++) {
|
||||
ptr->X = coords[edgeIndices[i + 0]].X;
|
||||
ptr->Y = coords[edgeIndices[i + 1]].Y;
|
||||
ptr->Z = coords[edgeIndices[i + 2]].Z;
|
||||
ptr->Col = col;
|
||||
}
|
||||
*lineVertices = ptr;
|
||||
}
|
||||
|
||||
void SelectionBox_VerQuad(VertexP3fC4b** vertices, PackedCol col,
|
||||
@ -69,16 +83,6 @@ void SelectionBox_HorQuad(VertexP3fC4b** vertices, PackedCol col,
|
||||
*vertices = ptr;
|
||||
}
|
||||
|
||||
void SelectionBox_Line(VertexP3fC4b** vertices, PackedCol col,
|
||||
Real32 x1, Real32 y1, Real32 z1, Real32 x2, Real32 y2, Real32 z2) {
|
||||
VertexP3fC4b* ptr = *vertices;
|
||||
VertexP3fC4b v; v.Col = col;
|
||||
|
||||
v.X = x1; v.Y = y1; v.Z = z1; *ptr++ = v;
|
||||
v.X = x2; v.Y = y2; v.Z = z2; *ptr++ = v;
|
||||
*vertices = ptr;
|
||||
}
|
||||
|
||||
|
||||
static Int32 SelectionBox_Compare(struct SelectionBox* a, struct SelectionBox* b) {
|
||||
Real32 aDist, bDist;
|
||||
|
Loading…
x
Reference in New Issue
Block a user