Permalink
Browse files

Merge branch 'master' of https://github.com/UnknownShadow200/Classica…

  • Loading branch information...
Goodlyay committed Jan 7, 2019
2 parents 790b1c0 + 518b7b8 commit 1525434f06bded2b3048be4a7dddbbc89552a172
@@ -47,7 +47,7 @@
<StartAction>Project</StartAction>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug_D3D' ">
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<OutputPath>..\output\debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
@@ -37,7 +37,7 @@ void AxisLinesRenderer_Render(double delta) {

Gfx_SetTexturing(false);
pos = LocalPlayer_Instance.Base.Position; pos.Y += 0.05f;
count = Camera_Active->IsThirdPerson ? 12 : 8;
count = Camera.Active->IsThirdPerson ? 12 : 8;

Vector3_Add1(&coords[0], &pos, -AXISLINES_LENGTH);
Vector3_Add1(&coords[1], &pos, -AXISLINES_THICKNESS);
@@ -8,14 +8,7 @@
#include "Entity.h"
#include "Input.h"

int Camera_Sensitivity;
bool Camera_Smooth, Camera_Clipping, Camera_Invert;

struct Matrix Camera_TiltM;
float Camera_BobbingVer, Camera_BobbingHor;
Vector3 Camera_CurrentPos;
struct Camera* Camera_Active;

struct _CameraData Camera;
static struct PickedPos cameraClipPos;
static Vector2 cam_rotOffset;
static bool cam_isForwardThird;
@@ -30,10 +23,10 @@ static void PerspectiveCamera_GetProjection(struct Matrix* proj) {
}

static void PerspectiveCamera_GetView(struct Matrix* mat) {
Vector3 pos = Camera_CurrentPos;
Vector2 rot = Camera_Active->GetOrientation();
Vector3 pos = Camera.CurrentPos;
Vector2 rot = Camera.Active->GetOrientation();
Matrix_LookRot(mat, pos, rot);
Matrix_MulBy(mat, &Camera_TiltM);
Matrix_MulBy(mat, &Camera.TiltM);
}

static void PerspectiveCamera_GetPickedBlock(struct PickedPos* pos) {
@@ -66,11 +59,11 @@ static void PerspectiveCamera_RegrabMouse(void) {
#define CAMERA_ADJUST 0.025f

static Vector2 PerspectiveCamera_GetMouseDelta(void) {
float sensitivity = CAMERA_SENSI_FACTOR * Camera_Sensitivity;
float sensitivity = CAMERA_SENSI_FACTOR * Camera.Sensitivity;
static float speedX, speedY;
Vector2 v;

if (Camera_Smooth) {
if (Camera.Smooth) {
speedX += cam_delta.X * CAMERA_ADJUST;
speedX *= CAMERA_SLIPPERY;
speedY += cam_delta.Y * CAMERA_ADJUST;
@@ -81,7 +74,7 @@ static Vector2 PerspectiveCamera_GetMouseDelta(void) {
}

v.X = speedX * sensitivity; v.Y = speedY * sensitivity;
if (Camera_Invert) v.Y = -v.Y;
if (Camera.Invert) v.Y = -v.Y;
return v;
}

@@ -93,7 +86,7 @@ static void PerspectiveCamera_UpdateMouseRotation(void) {
float headY, headX;
Vector2 rot = PerspectiveCamera_GetMouseDelta();

if (Key_IsAltPressed() && Camera_Active->IsThirdPerson) {
if (Key_IsAltPressed() && Camera.Active->IsThirdPerson) {
cam_rotOffset.X += rot.X; cam_rotOffset.Y += rot.Y;
return;
}
@@ -127,20 +120,20 @@ static void PerspectiveCamera_CalcViewBobbing(float t, float velTiltScale) {
struct LocalPlayer* p = &LocalPlayer_Instance;
struct Entity* e = &p->Base;

struct Matrix Camera_tiltY, Camera_velX;
struct Matrix tiltY, velX;
float vel;
if (!Game_ViewBobbing) { Camera_TiltM = Matrix_Identity; return; }
if (!Game_ViewBobbing) { Camera.TiltM = Matrix_Identity; return; }

Matrix_RotateZ(&Camera_TiltM, -p->Tilt.TiltX * e->Anim.BobStrength);
Matrix_RotateX(&Camera_tiltY, Math_AbsF(p->Tilt.TiltY) * 3.0f * e->Anim.BobStrength);
Matrix_MulBy(&Camera_TiltM, &Camera_tiltY);
Matrix_RotateZ(&Camera.TiltM, -p->Tilt.TiltX * e->Anim.BobStrength);
Matrix_RotateX(&tiltY, Math_AbsF(p->Tilt.TiltY) * 3.0f * e->Anim.BobStrength);
Matrix_MulBy(&Camera.TiltM, &tiltY);

Camera_BobbingHor = (e->Anim.BobbingHor * 0.3f) * e->Anim.BobStrength;
Camera_BobbingVer = (e->Anim.BobbingVer * 0.6f) * e->Anim.BobStrength;
Camera.BobbingHor = (e->Anim.BobbingHor * 0.3f) * e->Anim.BobStrength;
Camera.BobbingVer = (e->Anim.BobbingVer * 0.6f) * e->Anim.BobStrength;

vel = Math_Lerp(p->OldVelocity.Y + 0.08f, e->Velocity.Y + 0.08f, t);
Matrix_RotateX(&Camera_velX, -vel * 0.05f * p->Tilt.VelTiltStrength / velTiltScale);
Matrix_MulBy(&Camera_TiltM, &Camera_velX);
Matrix_RotateX(&velX, -vel * 0.05f * p->Tilt.VelTiltStrength / velTiltScale);
Matrix_MulBy(&Camera.TiltM, &velX);
}


@@ -160,9 +153,9 @@ static Vector3 FirstPersonCamera_GetPosition(float t) {
float headY = p->HeadY * MATH_DEG2RAD;
PerspectiveCamera_CalcViewBobbing(t, 1);

camPos.Y += Camera_BobbingVer;
camPos.X += Camera_BobbingHor * (float)Math_Cos(headY);
camPos.Z += Camera_BobbingHor * (float)Math_Sin(headY);
camPos.Y += Camera.BobbingVer;
camPos.X += Camera.BobbingHor * (float)Math_Cos(headY);
camPos.Z += Camera.BobbingHor * (float)Math_Sin(headY);
return camPos;
}

@@ -200,9 +193,9 @@ static Vector3 ThirdPersonCamera_GetPosition(float t) {

PerspectiveCamera_CalcViewBobbing(t, dist);
target = Entity_GetEyePosition(p);
target.Y += Camera_BobbingVer;
target.Y += Camera.BobbingVer;

rot = Camera_Active->GetOrientation();
rot = Camera.Active->GetOrientation();
dir = Vector3_GetDirVector(rot.X, rot.Y);
Vector3_Negate(&dir, &dir);

@@ -241,21 +234,21 @@ void Camera_Init(void) {
Camera_FirstPerson.Next = &Camera_ThirdPerson;
Camera_ThirdPerson.Next = &Camera_ForwardThird;
Camera_ForwardThird.Next = &Camera_FirstPerson;
Camera_Active = &Camera_FirstPerson;
Camera.Active = &Camera_FirstPerson;

Camera_Sensitivity = Options_GetInt(OPT_SENSITIVITY, 1, 100, 30);
Camera_Clipping = Options_GetBool(OPT_CAMERA_CLIPPING, true);
Camera_Invert = Options_GetBool(OPT_INVERT_MOUSE, false);
Camera.Sensitivity = Options_GetInt(OPT_SENSITIVITY, 1, 100, 30);
Camera.Clipping = Options_GetBool(OPT_CAMERA_CLIPPING, true);
Camera.Invert = Options_GetBool(OPT_INVERT_MOUSE, false);
}

void Camera_CycleActive(void) {
struct LocalPlayer* p = &LocalPlayer_Instance;
if (Game_ClassicMode) return;
Camera_Active = Camera_Active->Next;
Camera.Active = Camera.Active->Next;

cam_isForwardThird = Camera_Active == &Camera_ForwardThird;
cam_isForwardThird = Camera.Active == &Camera_ForwardThird;
if (!p->Hacks.CanUseThirdPersonCamera || !p->Hacks.Enabled) {
Camera_Active = &Camera_FirstPerson;
Camera.Active = &Camera_FirstPerson;
}

/* reset rotation offset when changing cameras */
@@ -8,21 +8,27 @@
struct PickedPos;
struct Camera;

/* How sensitive camera is to movements of mouse. */
extern int Camera_Sensitivity;
/* Whether smooth/cinematic camera mode is used. */
extern bool Camera_Smooth;
/* Whether third person camera clip against blocks. */
extern bool Camera_Clipping;
/* Whether to invert vertical mouse movement. */
extern bool Camera_Invert;

/* Tilt effect applied to the camera. */
extern struct Matrix Camera_TiltM;
/* Bobbing offset of camera from player's eye. */
extern float Camera_BobbingVer, Camera_BobbingHor;
/* Cached position the camera is at. */
extern Vector3 Camera_CurrentPos;
/* Shared data for cameras. */
struct _CameraData {
/* How sensitive camera is to movements of mouse. */
int Sensitivity;
/* Whether smooth/cinematic camera mode is used. */
bool Smooth;
/* Whether third person camera clip against blocks. */
bool Clipping;
/* Whether to invert vertical mouse movement. */
bool Invert;

/* Tilt effect applied to the camera. */
struct Matrix TiltM;
/* Bobbing offset of camera from player's eye. */
float BobbingVer, BobbingHor;

/* Cached position the camera is at. */
Vector3 CurrentPos;
/* Camera user is currently using. */
struct Camera* Active;
} Camera;

struct Camera {
/* Whether this camera is third person. (i.e. not allowed when -thirdperson in MOTD) */
@@ -53,8 +59,6 @@ struct Camera {
bool (*Zoom)(float amount);
};

/* Camera user is currently using. */
extern struct Camera* Camera_Active;
/* Initialises the default cameras. */
void Camera_Init(void);
/* Switches to the next camera in the list. */
@@ -4,7 +4,7 @@
#include "Event.h"
#include "Game.h"
#include "Logger.h"
#include "ServerConnection.h"
#include "Server.h"
#include "World.h"
#include "Inventory.h"
#include "Entity.h"
@@ -209,7 +209,7 @@ static bool Commands_IsCommandPrefix(const String* str) {
const static String prefix = String_FromConst(COMMANDS_PREFIX);

if (!str->length) return false;
if (ServerConnection_IsSinglePlayer && str->buffer[0] == '/') return true;
if (Server.IsSinglePlayer && str->buffer[0] == '/') return true;

return String_CaselessStarts(str, &prefixSpace)
|| String_CaselessEquals(str, &prefix);
@@ -246,7 +246,7 @@ static struct ChatCommand* Commands_GetMatch(const String* cmdName) {
Chat_AddRaw("&e/client: Type &a/client &efor a list of commands.");
return NULL;
}
if (match->SingleplayerOnly && !ServerConnection_IsSinglePlayer) {
if (match->SingleplayerOnly && !Server.IsSinglePlayer) {
Chat_Add1("&e/client: \"&f%s&e\" can only be used in singleplayer.", cmdName);
return NULL;
}
@@ -560,7 +560,7 @@ void Chat_Send(const String* text, bool logUsage) {
if (Commands_IsCommandPrefix(text)) {
Commands_Execute(text);
} else {
ServerConnection.SendChat(text);
Server.SendChat(text);
}
}

@@ -232,7 +232,7 @@
<ClInclude Include="Resources.h" />
<ClInclude Include="Screens.h" />
<ClInclude Include="SelectionBox.h" />
<ClInclude Include="ServerConnection.h" />
<ClInclude Include="Server.h" />
<ClInclude Include="Stream.h" />
<ClInclude Include="GameStructs.h" />
<ClInclude Include="TexturePack.h" />
@@ -300,7 +300,7 @@
<ClCompile Include="Resources.c" />
<ClCompile Include="Screens.c" />
<ClCompile Include="SelectionBox.c" />
<ClCompile Include="ServerConnection.c" />
<ClCompile Include="Server.c" />
<ClCompile Include="Stream.c" />
<ClCompile Include="String.c" />
<ClCompile Include="TexturePack.c" />
@@ -231,9 +231,6 @@
<ClInclude Include="Chat.h">
<Filter>Header Files\Game</Filter>
</ClInclude>
<ClInclude Include="ServerConnection.h">
<Filter>Header Files\Network</Filter>
</ClInclude>
<ClInclude Include="Event.h">
<Filter>Header Files\Game</Filter>
</ClInclude>
@@ -318,6 +315,9 @@
<ClInclude Include="Http.h">
<Filter>Header Files\Network</Filter>
</ClInclude>
<ClInclude Include="Server.h">
<Filter>Header Files\Network</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="String.c">
@@ -413,9 +413,6 @@
<ClCompile Include="Chat.c">
<Filter>Source Files\Game</Filter>
</ClCompile>
<ClCompile Include="ServerConnection.c">
<Filter>Source Files\Network</Filter>
</ClCompile>
<ClCompile Include="Event.c">
<Filter>Source Files\Game</Filter>
</ClCompile>
@@ -563,5 +560,8 @@
<ClCompile Include="Http.c">
<Filter>Source Files\Network</Filter>
</ClCompile>
<ClCompile Include="Server.c">
<Filter>Source Files\Network</Filter>
</ClCompile>
</ItemGroup>
</Project>
@@ -24,6 +24,7 @@ typedef signed __int64 int64_t;
#define CC_ALIGN_HINT(x) __declspec(align(x))
#ifndef CC_API
#define CC_API __declspec(dllexport, noinline)
#define CC_VAR __declspec(dllexport)
#endif
#elif __GNUC__
#include <stdint.h>
@@ -33,8 +34,10 @@ typedef signed __int64 int64_t;
#ifndef CC_API
#ifdef _WIN32
#define CC_API __attribute__((dllexport, noinline))
#define CC_VAR __attribute__((dllexport))
#else
#define CC_API __attribute__((visibility("default"), noinline))
#define CC_VAR __attribute__((visibility("default")))
#endif
#endif
#else
@@ -6,7 +6,7 @@
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/

extern struct _DrawerData {
CC_VAR extern struct _DrawerData {
/* Whether a colour tinting effect should be applied to all faces. */
bool Tinted;
/* The colour to multiply colour of faces by (tinting effect). */
@@ -22,15 +22,15 @@ extern struct _DrawerData {
} Drawer;

/* Draws minimum X face of the cuboid. (i.e. at X1) */
void Drawer_XMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
CC_API void Drawer_XMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws maximum X face of the cuboid. (i.e. at X2) */
void Drawer_XMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
CC_API void Drawer_XMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws minimum Z face of the cuboid. (i.e. at Z1) */
void Drawer_ZMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
CC_API void Drawer_ZMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws maximum Z face of the cuboid. (i.e. at Z2) */
void Drawer_ZMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
CC_API void Drawer_ZMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws minimum Y face of the cuboid. (i.e. at Y1) */
void Drawer_YMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
CC_API void Drawer_YMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws maximum Y face of the cuboid. (i.e. at Y2) */
void Drawer_YMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
CC_API void Drawer_YMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
#endif
@@ -865,12 +865,12 @@ static void LocalPlayer_RenderModel(struct Entity* e, double deltaTime, float t)
AnimatedComp_GetCurrent(e, t);
TiltComp_GetCurrent(&p->Tilt, t);

if (!Camera_Active->IsThirdPerson) return;
if (!Camera.Active->IsThirdPerson) return;
Model_Render(e->Model, e);
}

static void LocalPlayer_RenderName(struct Entity* e) {
if (!Camera_Active->IsThirdPerson) return;
if (!Camera.Active->IsThirdPerson) return;
Player_DrawName((struct Player*)e);
}

@@ -116,7 +116,7 @@ bool Entity_TouchesAnyWater(struct Entity* e);

/* Global data for all entities */
/* (Actual entities may point to NetPlayers_List or elsewhere) */
extern struct _EntitiesData {
CC_VAR extern struct _EntitiesData {
struct Entity* List[ENTITIES_MAX_COUNT];
uint8_t NamesMode, ShadowsMode;
} Entities;
@@ -138,7 +138,7 @@ void Entities_DrawShadows(void);

#define TABLIST_MAX_NAMES 256
/* Data for all entries in tab list */
extern struct _TabListData {
CC_VAR extern struct _TabListData {
uint16_t PlayerNames[TABLIST_MAX_NAMES];
uint16_t ListNames[TABLIST_MAX_NAMES];
uint16_t GroupNames[TABLIST_MAX_NAMES];
Oops, something went wrong.

0 comments on commit 1525434

Please sign in to comment.