mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
fix c client always playing hal2 (oops)
This commit is contained in:
parent
a0c544392b
commit
9d50f20dba
@ -395,7 +395,7 @@ static void Music_RunLoop(void) {
|
|||||||
|
|
||||||
while (!music_pendingStop) {
|
while (!music_pendingStop) {
|
||||||
Int32 idx = Random_Range(&rnd, 0, count);
|
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 path = String_InitAndClearArray(pathBuffer);
|
||||||
String_Format2(&path, "audio%r%s", &Directory_Separator, &filename);
|
String_Format2(&path, "audio%r%s", &Directory_Separator, &filename);
|
||||||
Platform_Log1("playing music file: %s", &filename);
|
Platform_Log1("playing music file: %s", &filename);
|
||||||
|
@ -339,7 +339,7 @@ void Block_RecalculateBB(BlockID block) {
|
|||||||
maxY = Block_GetSpriteBB_MaxY(tileSize, x, y, bmp);
|
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 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);
|
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);
|
Vector3I_ToVector3(&translated, &Game_SelectedPos.TranslatedPos);
|
||||||
Vector3_Sub(&offset, &Game_SelectedPos.Intersect, &translated);
|
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);
|
return AutoRotate_RotateCorner(block, &baseName, offset);
|
||||||
} else if (AR_EQ1(dir, 'u') || AR_EQ1(dir, 'd')) {
|
} else if (AR_EQ1(dir, 'u') || AR_EQ1(dir, 'd')) {
|
||||||
return AutoRotate_RotateVertical(block, &baseName, offset);
|
return AutoRotate_RotateVertical(block, &baseName, offset);
|
||||||
} else if (AR_EQ1(dir, 'n') || AR_EQ1(dir, 'w') || AR_EQ1(dir, 's') || AR_EQ1(dir, 'e')) {
|
} else if (AR_EQ1(dir, 'n') || AR_EQ1(dir, 'w') || AR_EQ1(dir, 's') || AR_EQ1(dir, 'e')) {
|
||||||
return AutoRotate_RotateDirection(block, &baseName, offset);
|
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 AutoRotate_RotateOther(block, &baseName, offset);
|
||||||
}
|
}
|
||||||
return block;
|
return block;
|
||||||
|
@ -403,7 +403,6 @@ struct Size2D Drawer2D_MeasureText(struct DrawTextArgs* args) {
|
|||||||
struct Size2D size = { 0, 0 };
|
struct Size2D size = { 0, 0 };
|
||||||
|
|
||||||
while (i < value.length) {
|
while (i < value.length) {
|
||||||
UChar col = nextCol;
|
|
||||||
i = Drawer2D_NextPart(i, &value, &args->Text, &nextCol);
|
i = Drawer2D_NextPart(i, &value, &args->Text, &nextCol);
|
||||||
if (!args->Text.length) continue;
|
if (!args->Text.length) continue;
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@ Real32 Math_Lerp(Real32 a, Real32 b, Real32 t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Real32 Math_LerpAngle(Real32 leftAngle, Real32 rightAngle, Real32 t) {
|
Real32 Math_LerpAngle(Real32 leftAngle, Real32 rightAngle, Real32 t) {
|
||||||
/* we have to cheat a bit for angles here. */
|
/* We have to cheat a bit for angles here */
|
||||||
/* Consider 350* --> 0*, we only want to travel 10*, */
|
/* Consider 350* --> 0*, we only want to travel 10* */
|
||||||
/* but without adjusting for this case, we would interpolate back the whole 350* degrees.*/
|
/* But without adjusting for this case, we would interpolate back the whole 350* degrees */
|
||||||
bool invertLeft = leftAngle > 270.0f && rightAngle < 90.0f;
|
bool invertLeft = leftAngle > 270.0f && rightAngle < 90.0f;
|
||||||
bool invertRight = rightAngle > 270.0f && leftAngle < 90.0f;
|
bool invertRight = rightAngle > 270.0f && leftAngle < 90.0f;
|
||||||
if (invertLeft) leftAngle = leftAngle - 360.0f;
|
if (invertLeft) leftAngle = leftAngle - 360.0f;
|
||||||
|
@ -501,7 +501,7 @@ void Game_Load(void) {
|
|||||||
}
|
}
|
||||||
Game_InitScheduledTasks();
|
Game_InitScheduledTasks();
|
||||||
|
|
||||||
/* TODO: plugin dll support * /
|
/* TODO: plugin dll support */
|
||||||
/* if (nonLoaded != null) {
|
/* if (nonLoaded != null) {
|
||||||
for (int i = 0; i < nonLoaded.Count; i++) {
|
for (int i = 0; i < nonLoaded.Count; i++) {
|
||||||
Overlay warning = new PluginOverlay(this, nonLoaded[i]);
|
Overlay warning = new PluginOverlay(this, nonLoaded[i]);
|
||||||
|
@ -51,7 +51,7 @@ static void HeldBlockRenderer_RenderModel(void) {
|
|||||||
|
|
||||||
static void HeldBlockRenderer_SetMatrix(void) {
|
static void HeldBlockRenderer_SetMatrix(void) {
|
||||||
struct Entity* player = &LocalPlayer_Instance.Base;
|
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;
|
struct Matrix m, lookAt;
|
||||||
Matrix_Translate(&lookAt, -eye.X, -eye.Y, -eye.Z);
|
Matrix_Translate(&lookAt, -eye.X, -eye.Y, -eye.Z);
|
||||||
@ -62,8 +62,8 @@ static void HeldBlockRenderer_SetMatrix(void) {
|
|||||||
static void HeldBlockRenderer_ResetHeldState(void) {
|
static void HeldBlockRenderer_ResetHeldState(void) {
|
||||||
/* Based off details from http://pastebin.com/KFV0HkmD (Thanks goodlyay!) */
|
/* Based off details from http://pastebin.com/KFV0HkmD (Thanks goodlyay!) */
|
||||||
struct Entity* player = &LocalPlayer_Instance.Base;
|
struct Entity* player = &LocalPlayer_Instance.Base;
|
||||||
Vector3 eyePos = VECTOR3_CONST(0.0f, Entity_GetEyeHeight(player), 0.0f);
|
Vector3 eye = { 0, Entity_GetEyeHeight(player), 0 };
|
||||||
held_entity.Position = eyePos;
|
held_entity.Position = eye;
|
||||||
|
|
||||||
held_entity.Position.X -= Camera_BobbingHor;
|
held_entity.Position.X -= Camera_BobbingHor;
|
||||||
held_entity.Position.Y -= Camera_BobbingVer;
|
held_entity.Position.Y -= Camera_BobbingVer;
|
||||||
|
18
src/IModel.c
18
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,
|
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) {
|
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; }
|
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, 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, 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,
|
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) {
|
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; }
|
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], 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, 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,
|
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) {
|
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; }
|
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], 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, 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++;
|
||||||
}
|
}
|
||||||
|
@ -2602,13 +2602,6 @@ static void GuiOptionsScreen_SetUseFont(STRING_PURE String* v) {
|
|||||||
Menu_HandleFontChange((struct GuiElem*)&MenuOptionsScreen_Instance);
|
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) {
|
static void GuiOptionsScreen_ContextRecreated(void* obj) {
|
||||||
struct MenuOptionsScreen* screen = (struct MenuOptionsScreen*)obj;
|
struct MenuOptionsScreen* screen = (struct MenuOptionsScreen*)obj;
|
||||||
struct Widget** widgets = screen->Widgets;
|
struct Widget** widgets = screen->Widgets;
|
||||||
|
@ -1110,8 +1110,8 @@ static Real32 BlockModel_GetEyeY(struct Entity* entity) {
|
|||||||
static void BlockModel_GetCollisionSize(Vector3* size) {
|
static void BlockModel_GetCollisionSize(Vector3* size) {
|
||||||
Vector3_Sub(size, &BlockModel_maxBB, &BlockModel_minBB);
|
Vector3_Sub(size, &BlockModel_maxBB, &BlockModel_minBB);
|
||||||
/* to fit slightly inside */
|
/* to fit slightly inside */
|
||||||
Vector3 sizeShrink = VECTOR3_CONST1(0.75f / 16.0f);
|
static Vector3 shrink = { 0.75f/16.0f, 0.75f/16.0f, 0.75f/16.0f };
|
||||||
Vector3_SubBy(size, &sizeShrink);
|
Vector3_SubBy(size, &shrink);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlockModel_GetPickingBounds(struct AABB* bb) {
|
static void BlockModel_GetPickingBounds(struct AABB* bb) {
|
||||||
|
@ -618,7 +618,7 @@ static void Classic_ReadAbsoluteLocation(UInt8* data, EntityID id, bool interpol
|
|||||||
y -= 51; /* Convert to feet position */
|
y -= 51; /* Convert to feet position */
|
||||||
if (id == ENTITIES_SELF_ID) y += 22;
|
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 rotY = Math_Packed2Deg(*data++);
|
||||||
Real32 headX = Math_Packed2Deg(*data++);
|
Real32 headX = Math_Packed2Deg(*data++);
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ static bool Picking_ClipBlock(struct PickedPos* pos) {
|
|||||||
return true;
|
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) {
|
static bool Picking_ClipCamera(struct PickedPos* pos) {
|
||||||
if (Block_Draw[tracer.Block] == DRAW_GAS || Block_Collide[tracer.Block] != COLLIDE_SOLID) return false;
|
if (Block_Draw[tracer.Block] == DRAW_GAS || Block_Collide[tracer.Block] != COLLIDE_SOLID) return false;
|
||||||
Real32 t0, t1;
|
Real32 t0, t1;
|
||||||
|
@ -112,18 +112,18 @@ int main(void) {
|
|||||||
String bits[4]; UInt32 bitsCount = Array_Elems(bits);
|
String bits[4]; UInt32 bitsCount = Array_Elems(bits);
|
||||||
String_UNSAFE_Split(&args[2], '.', bits, &bitsCount);
|
String_UNSAFE_Split(&args[2], '.', bits, &bitsCount);
|
||||||
if (bitsCount != Array_Elems(bits)) {
|
if (bitsCount != Array_Elems(bits)) {
|
||||||
Platform_LogConst("Invalid IP"); return;
|
Platform_LogConst("Invalid IP"); return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt8 ipTmp;
|
UInt8 ipTmp;
|
||||||
if (!Convert_TryParseUInt8(&bits[0], &ipTmp) || !Convert_TryParseUInt8(&bits[1], &ipTmp) ||
|
if (!Convert_TryParseUInt8(&bits[0], &ipTmp) || !Convert_TryParseUInt8(&bits[1], &ipTmp) ||
|
||||||
!Convert_TryParseUInt8(&bits[2], &ipTmp) || !Convert_TryParseUInt8(&bits[3], &ipTmp)) {
|
!Convert_TryParseUInt8(&bits[2], &ipTmp) || !Convert_TryParseUInt8(&bits[3], &ipTmp)) {
|
||||||
Platform_LogConst("Invalid IP"); return;
|
Platform_LogConst("Invalid IP"); return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt16 portTmp;
|
UInt16 portTmp;
|
||||||
if (!Convert_TryParseUInt16(&args[3], &portTmp)) {
|
if (!Convert_TryParseUInt16(&args[3], &portTmp)) {
|
||||||
Platform_LogConst("Invalid port"); return;
|
Platform_LogConst("Invalid port"); return 1;
|
||||||
}
|
}
|
||||||
Game_Port = portTmp;
|
Game_Port = portTmp;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ Vector3I Vector3I_MaxValue(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3_BigPos(void) {
|
Vector3 Vector3_BigPos(void) {
|
||||||
Vector3 v = VECTOR3_CONST1(1e25f); return v;
|
Vector3 v = { 1e25f, 1e25f, 1e25f }; return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Real32 Vector3_LengthSquared(Vector3* v) {
|
Real32 Vector3_LengthSquared(Vector3* v) {
|
||||||
|
@ -19,7 +19,6 @@ Vector3I Vector3I_MaxValue(void);
|
|||||||
Vector3 Vector3_BigPos(void);
|
Vector3 Vector3_BigPos(void);
|
||||||
Real32 Vector3_LengthSquared(Vector3* v);
|
Real32 Vector3_LengthSquared(Vector3* v);
|
||||||
|
|
||||||
#define VECTOR3_CONST1(val) { val, val, val };
|
|
||||||
#define VECTOR3_CONST(x, y, z) { x, y, z };
|
#define VECTOR3_CONST(x, y, z) { x, y, z };
|
||||||
#define Vector3_UnitX VECTOR3_CONST(1.0f, 0.0f, 0.0f)
|
#define Vector3_UnitX VECTOR3_CONST(1.0f, 0.0f, 0.0f)
|
||||||
#define Vector3_UnitY VECTOR3_CONST(0.0f, 1.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)
|
#define Vector3_Mul3By(dst, value) Vector3_Mul3(dst, dst, value)
|
||||||
|
|
||||||
void Vector3_Lerp(Vector3* result, Vector3* a, Vector3* b, Real32 blend);
|
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_Normalize(Vector3* result, Vector3* a);
|
||||||
|
|
||||||
void Vector3_Transform(Vector3* result, Vector3* a, struct Matrix* mat);
|
void Vector3_Transform(Vector3* result, Vector3* a, struct Matrix* mat);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user