Combine and enable various C files.

This commit is contained in:
UnknownShadow200 2017-08-24 19:45:43 +10:00
parent 53180c0f87
commit 84b8e2048c
29 changed files with 330 additions and 397 deletions

View File

@ -101,7 +101,7 @@ namespace ClassicalSharp.Model {
(skinType == SkinType.Type64x64 ? Set64 : Set);
DrawRotate(-p.HeadXRadians, 0, 0, model.Head, true);
DrawPart(model.Torso);
DrawPart(model.Torso); DateTime.UtcNow.mi
DrawRotate(p.anim.leftLegX, 0, p.anim.leftLegZ, model.LeftLeg, false);
DrawRotate(p.anim.rightLegX, 0, p.anim.rightLegZ, model.RightLeg, false);

View File

@ -13,24 +13,6 @@
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Sides of a block. TODO: Map this to CPE PlayerClicked blockface enums. */
typedef UInt8 Face;
/* Face X = 0. */
#define Face_XMin 0
/* Face X = 1. */
#define Face_XMax 1
/* Face Z = 0. */
#define Face_ZMin 2
/* Face Z = 1. */
#define Face_ZMax 3
/* Face Y = 0. */
#define Face_YMin 4
/* Face Y = 1. */
#define Face_YMax 5
/* Number of faces on a cube. */
#define Face_Count 6
/* Sound types for blocks. */
typedef UInt8 SoundType;
#define SoundType_None 0

View File

@ -4,7 +4,6 @@
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Classic blocks */
#define BlockID_Air 0
#define BlockID_Stone 1

View File

@ -175,7 +175,6 @@
<ItemGroup>
<ClInclude Include="2DStructs.h" />
<ClInclude Include="AABB.h" />
<ClInclude Include="AnimatedComp.h" />
<ClInclude Include="AutoRotate.h" />
<ClInclude Include="AxisLinesRenderer.h" />
<ClInclude Include="BlockID.h" />
@ -198,15 +197,14 @@
<ClInclude Include="Event.h" />
<ClInclude Include="Events.h" />
<ClInclude Include="FrustumCulling.h" />
<ClInclude Include="GameProps.h" />
<ClInclude Include="GZipHeader.h" />
<ClInclude Include="EntityComponents.h" />
<ClInclude Include="IModel.h" />
<ClInclude Include="Intersection.h" />
<ClInclude Include="IsometricDrawer.h" />
<ClInclude Include="Lighting.h" />
<ClInclude Include="BordersRenderer.h" />
<ClInclude Include="LiquidAnimations.h" />
<ClInclude Include="LocalPlayer.h" />
<ClInclude Include="MapGenerator.h" />
<ClInclude Include="MapRenderer.h" />
<ClInclude Include="ModelCache.h" />
@ -226,7 +224,6 @@
<ClInclude Include="GameStructs.h" />
<ClInclude Include="TerrainAtlas.h" />
<ClInclude Include="TickQueue.h" />
<ClInclude Include="TiltComp.h" />
<ClInclude Include="TreeGen.h" />
<ClInclude Include="WeatherRenderer.h" />
<ClInclude Include="PackedCol.h" />
@ -251,7 +248,7 @@
<ItemGroup>
<ClCompile Include="2DStructs.c" />
<ClCompile Include="AABB.c" />
<ClCompile Include="AnimatedComp.c" />
<ClCompile Include="EntityComponents.c" />
<ClCompile Include="AutoRotate.c" />
<ClCompile Include="AxisLinesRenderer.c" />
<ClCompile Include="Block.c" />

View File

@ -148,9 +148,6 @@
<Filter Include="Source Files\Entities\Components">
<UniqueIdentifier>{45bcb3f5-ebec-46a0-ac73-8480a7b4fe4d}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Entities\Components">
<UniqueIdentifier>{e36a6223-ce95-4439-aa54-df32b9828ae0}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Platform\Window">
<UniqueIdentifier>{e4324350-79a5-4976-a8cc-28881077ca9a}</UniqueIdentifier>
</Filter>
@ -246,9 +243,6 @@
<ClInclude Include="PickedPos.h">
<Filter>Header Files\Math</Filter>
</ClInclude>
<ClInclude Include="GameProps.h">
<Filter>Header Files\Game</Filter>
</ClInclude>
<ClInclude Include="NetworkEnums.h">
<Filter>Header Files\Network</Filter>
</ClInclude>
@ -315,9 +309,6 @@
<ClInclude Include="PickedPosRenderer.h">
<Filter>Header Files\SelectionBox</Filter>
</ClInclude>
<ClInclude Include="LocalPlayer.h">
<Filter>Header Files\Entities</Filter>
</ClInclude>
<ClInclude Include="Player.h">
<Filter>Header Files\Entities</Filter>
</ClInclude>
@ -354,12 +345,6 @@
<ClInclude Include="AutoRotate.h">
<Filter>Header Files\Blocks</Filter>
</ClInclude>
<ClInclude Include="AnimatedComp.h">
<Filter>Header Files\Entities\Components</Filter>
</ClInclude>
<ClInclude Include="TiltComp.h">
<Filter>Header Files\Entities\Components</Filter>
</ClInclude>
<ClInclude Include="DisplayDevice.h">
<Filter>Header Files\Platform\Window</Filter>
</ClInclude>
@ -381,6 +366,9 @@
<ClInclude Include="TerrainAtlas.h">
<Filter>Header Files\TexturePack</Filter>
</ClInclude>
<ClInclude Include="EntityComponents.h">
<Filter>Header Files\Entities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Noise.c">
@ -530,9 +518,6 @@
<ClCompile Include="AutoRotate.c">
<Filter>Source Files\Blocks</Filter>
</ClCompile>
<ClCompile Include="AnimatedComp.c">
<Filter>Source Files\Entities\Components</Filter>
</ClCompile>
<ClCompile Include="TiltComp.c">
<Filter>Source Files\Entities\Components</Filter>
</ClCompile>
@ -566,5 +551,8 @@
<ClCompile Include="Entity.c">
<Filter>Source Files\Entities</Filter>
</ClCompile>
<ClCompile Include="EntityComponents.c">
<Filter>Source Files\Entities\Components</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -28,4 +28,19 @@
/* Minor adjustment to max UV coords, to avoid pixel bleeding errors due to rounding. */
#define UV2_Scale (15.99f / 16.0f)
/* Face X = 0. */
#define Face_XMin 0
/* Face X = 1. */
#define Face_XMax 1
/* Face Z = 0. */
#define Face_ZMin 2
/* Face Z = 1. */
#define Face_ZMax 3
/* Face Y = 0. */
#define Face_YMin 4
/* Face Y = 1. */
#define Face_YMax 5
/* Number of faces on a cube. */
#define Face_Count 6
#endif

View File

@ -8,22 +8,16 @@
typedef struct DateTime_ {
/* Year of this point in time, ranges from 0 to 65535. */
UInt16 Year;
/* Month of this point in time, ranges from 1 to 12. */
UInt8 Month;
/* Day of this point in time, ranges from 1 to 31. */
UInt8 Day;
/* Hour of this point in time, ranges from 0 to 23. */
UInt8 Hour;
/* Minute of this point in time, ranges from 0 to 59. */
UInt8 Minute;
/* Second of this point in time, ranges from 0 to 59. */
UInt8 Second;
/* Milliseconds of this point in time, ranges from 0 to 999. */
UInt16 Milliseconds;
} DateTime;

View File

@ -1,4 +1,3 @@
#if 0
#include "Entity.h"
#include "ExtMath.h"
#include "World.h"
@ -97,4 +96,3 @@ bool Entity_TouchesAnyWater(Entity* entity) {
AABB_Offset(&bounds, &bounds, &entity_liqExpand);
return Entity_TouchesAny(&bounds, Entity_IsWater);
}
#endif

View File

@ -1,14 +1,15 @@
#if 0
#ifndef CS_ENTITY_H
#define CS_ENTITY_H
#include "IModel.h"
#include "Typedefs.h"
#include "Vectors.h"
#include "AABB.h"
#include "AnimatedComp.h"
#include "EntityComponents.h"
#include "GraphicsEnums.h"
/* Represents an in-game entity.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
typedef struct IModel_ IModel; /* Forward declaration */
/* Constant offset used to avoid floating point roundoff errors. */
@ -98,4 +99,3 @@ bool Entity_TouchesAnyLava(Entity* entity);
/* Determines whether any of the blocks that intersect the AABB of this entity are water or still water. */
bool Entity_TouchesAnyWater(Entity* entity);
#endif
#endif

View File

@ -1,7 +1,43 @@
#if 0
#include "AnimatedComp.h"
#include "EntityComponents.h"
#include "ExtMath.h"
#include "GameProps.h"
#include "Game.h"
#include "Player.h"
#define maxAngle (110 * MATH_DEG2RAD)
#define armMax (60.0f * MATH_DEG2RAD)
#define legMax (80.0f * MATH_DEG2RAD)
#define idleMax (3.0f * MATH_DEG2RAD)
#define idleXPeriod (2.0f * MATH_PI / 5.0f)
#define idleZPeriod (2.0f * MATH_PI / 3.5f)
void AnimatedComp_DoTilt(Real32* tilt, bool reduce) {
if (reduce) {
(*tilt) *= 0.84f;
} else {
(*tilt) += 0.1f;
}
Math_Clamp(*tilt, 0.0f, 1.0f);
}
void AnimatedComp_PerpendicularAnim(AnimatedComp* anim, Real32 flapSpeed, Real32 idleXRot, Real32 idleZRot, bool left) {
Real32 verAngle = 0.5f + 0.5f * Math_Sin(anim->WalkTime * flapSpeed);
Real32 zRot = -idleZRot - verAngle * anim->Swing * maxAngle;
Real32 horAngle = Math_Cos(anim->WalkTime) * anim->Swing * armMax * 1.5f;
Real32 xRot = idleXRot + horAngle;
if (left) {
anim->LeftArmX = xRot; anim->LeftArmZ = zRot;
} else {
anim->RightArmX = xRot; anim->RightArmZ = zRot;
}
}
void AnimatedComp_CalcHumanAnim(AnimatedComp* anim, Real32 idleXRot, Real32 idleZRot) {
AnimatedComp_PerpendicularAnim(anim, 0.23f, idleXRot, idleZRot, true);
AnimatedComp_PerpendicularAnim(anim, 0.28f, idleXRot, idleZRot, false);
anim->RightArmX = -anim->RightArmX; anim->RightArmZ = -anim->RightArmZ;
}
void AnimatedComp_Init(AnimatedComp* anim) {
anim->BobbingHor = 0.0f; anim->BobbingVer = 0.0f; anim->BobbingModel = 0.0f;
@ -37,11 +73,6 @@ void AnimatedComp_Update(AnimatedComp* anim, Vector3 oldPos, Vector3 newPos, Rea
}
}
#define armMax (60.0f * MATH_DEG2RAD)
#define legMax (80.0f * MATH_DEG2RAD)
#define idleMax (3.0f * MATH_DEG2RAD)
#define idleXPeriod (2.0f * MATH_PI / 5.0f)
#define idleZPeriod (2.0f * MATH_PI / 3.5f)
void AnimatedComp_GetCurrent(AnimatedComp* anim, Real32 t, bool calcHumanAnims) {
anim->Swing = Math_Lerp(anim->SwingO, anim->SwingN, t);
@ -69,33 +100,28 @@ void AnimatedComp_GetCurrent(AnimatedComp* anim, Real32 t, bool calcHumanAnims)
}
}
void AnimatedComp_DoTilt(Real32* tilt, bool reduce) {
if (reduce) {
(*tilt) *= 0.84f;
} else {
(*tilt) += 0.1f;
}
Math_Clamp(*tilt, 0.0f, 1.0f);
void TiltComp_Init(TiltComp* anim) {
anim->TiltX = 0.0f; anim->TiltY = 0.0f; anim->VelTiltStrength = 1.0f;
anim->VelTiltStrengthO = 1.0f; anim->VelTiltStrengthN = 1.0f;
}
void TiltComp_Update(TiltComp* anim, Real64 delta) {
anim->VelTiltStrengthO = anim->VelTiltStrengthN;
LocalPlayer* p = &LocalPlayer_Instance;
void AnimatedComp_CalcHumanAnim(AnimatedComp* anim, Real32 idleXRot, Real32 idleZRot) {
AnimatedComp_PerpendicularAnim(anim, 0.23f, idleXRot, idleZRot, true);
AnimatedComp_PerpendicularAnim(anim, 0.28f, idleXRot, idleZRot, false);
anim->RightArmX = -anim->RightArmX; anim->RightArmZ = -anim->RightArmZ;
}
#define maxAngle (110 * MATH_DEG2RAD)
void AnimatedComp_PerpendicularAnim(AnimatedComp* anim, Real32 flapSpeed, Real32 idleXRot, Real32 idleZRot, bool left) {
Real32 verAngle = 0.5f + 0.5f * Math_Sin(anim->WalkTime * flapSpeed);
Real32 zRot = -idleZRot - verAngle * anim->Swing * maxAngle;
Real32 horAngle = Math_Cos(anim->WalkTime) * anim->Swing * armMax * 1.5f;
Real32 xRot = idleXRot + horAngle;
if (left) {
anim->LeftArmX = xRot; anim->LeftArmZ = zRot;
} else {
anim->RightArmX = xRot; anim->RightArmZ = zRot;
/* TODO: the Tilt code was designed for 60 ticks/second, fix it up for 20 ticks/second */
Int32 i;
for (i = 0; i < 3; i++) {
AnimatedComp_DoTilt(&anim->VelTiltStrengthN, p->Hacks.Noclip || p->Hacks.Flying);
}
}
#endif
void TiltComp_GetCurrent(TiltComp* anim, Real32 t) {
LocalPlayer* p = &LocalPlayer_Instance;
anim->VelTiltStrength = Math_Lerp(anim->VelTiltStrengthO, anim->VelTiltStrengthN, t);
AnimatedComp* pAnim = &p->Base.Base.Anim;
anim->TiltX = Math_Cos(pAnim->WalkTime) * pAnim->Swing * (0.15f * MATH_DEG2RAD);
anim->TiltY = Math_Sin(pAnim->WalkTime) * pAnim->Swing * (0.15f * MATH_DEG2RAD);
}

View File

@ -0,0 +1,40 @@
#ifndef CS_ENTITYCOMPS_H
#define CS_ENTITYCOMPS_H
#include "Typedefs.h"
#include "Vectors.h"
/* Contains various components for entities.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Entity component that performs model animation depending on movement speed and time. */
typedef struct AnimatedComp_ {
Real32 BobbingHor, BobbingVer, BobbingModel;
Real32 WalkTime, Swing, BobStrength;
Real32 WalkTimeO, WalkTimeN, SwingO, SwingN, BobStrengthO, BobStrengthN;
Real32 LeftLegX, LeftLegZ, RightLegX, RightLegZ;
Real32 LeftArmX, LeftArmZ, RightArmX, RightArmZ;
} AnimatedComp;
/* Initalises default values for an animated component. */
void AnimatedComp_Init(AnimatedComp* anim);
/* Calculates the next model animation state based on old and new position. */
void AnimatedComp_Update(AnimatedComp* anim, Vector3 oldPos, Vector3 newPos, Real64 delta, bool onGround);
/* Calculates the interpolated state between the last and next model animation state. */
void AnimatedComp_GetCurrent(AnimatedComp* anim, Real32 t, bool calcHumanAnims);
/* Entity component that performs tilt animation depending on movement speed and time. */
typedef struct TiltComp_ {
Real32 TiltX, TiltY, VelTiltStrength;
Real32 VelTiltStrengthO, VelTiltStrengthN;
} TiltComp;
/* Initalises default values for a tilt component. */
void TiltComp_Init(TiltComp* anim);
/* Calculates the next tilt animation state. */
void TiltComp_Update(TiltComp* anim, Real64 delta);
/* Calculates the interpolated state between the last and next tilt animation state. */
void TiltComp_GetCurrent(TiltComp* anim, Real32 t);
#endif

View File

@ -1,4 +1,3 @@
#if 0
#include "FrustumCulling.h"
#include "ExtMath.h"
@ -9,6 +8,18 @@ frustum20, frustum21, frustum22, frustum23,
frustum30, frustum31, frustum32, frustum33,
frustum40, frustum41, frustum42, frustum43;
void FrustumCulling_Normalise(Real32* plane0, Real32* plane1, Real32* plane2, Real32* plane3) {
Real32 val1 = *plane0;
Real32 val2 = *plane1;
Real32 val3 = *plane2;
Real32 t = (Real32)Math_Sqrt(val1 * val1 + val2 * val2 + val3 * val3);
*plane0 /= t;
*plane1 /= t;
*plane2 /= t;
*plane3 /= t;
}
bool FrustumCulling_SphereInFrustum(Real32 x, Real32 y, Real32 z, Real32 radius) {
float d = frustum00 * x + frustum01 * y + frustum02 * z + frustum03;
if (d <= -radius) return false;
@ -68,16 +79,3 @@ void FrustumCulling_CalcFrustumEquations(Matrix* projection, Matrix* modelView)
frustum43 = clip[15] - clip[14];
FrustumCulling_Normalise(&frustum40, &frustum41, &frustum42, &frustum43);
}
void FrustumCulling_Normalise(Real32* plane0, Real32* plane1, Real32* plane2, Real32* plane3) {
Real32 val1 = *plane0;
Real32 val2 = *plane1;
Real32 val3 = *plane2;
Real32 t = (Real32)Math_Sqrt(val1 * val1 + val2 * val2 + val3 * val3);
*plane0 /= t;
*plane1 /= t;
*plane2 /= t;
*plane3 /= t;
}
#endif

View File

@ -1,4 +1,3 @@
#if 0
#ifndef CS_FRUSTUMCULLING_H
#define CS_FRUSTUMCULLING_H
#include "Matrix.h"
@ -13,7 +12,4 @@ bool FrustumCulling_SphereInFrustum(Real32 x, Real32 y, Real32 z, Real32 radius)
/* Calculates the planes that constitute view frustum. */
void FrustumCulling_CalcFrustumEquations(Matrix* projection, Matrix* modelView);
static void FrustumCulling_Normalise(Real32* plane0, Real32* plane1, Real32* plane2, Real32* plane3);
#endif
#endif

View File

@ -3,10 +3,169 @@
#include "Typedefs.h"
#include "Stream.h"
#include "GraphicsEnums.h"
#include "PickedPos.h"
#include "Options.h"
/* Represents the game.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Total rendering time(in seconds) elapsed since the client was started. */
Real64 Game_Accumulator;
/* Accumulator for the number of chunk updates performed. Reset every second. */
Int32 Game_ChunkUpdates;
/* Whether the third person camera should have their camera position clipped so as to not intersect blocks.*/
bool Game_CameraClipping;
/* Whether colour clear gfx call should be skipped. */
bool Game_SkipClear;
/* Picked pos instance used for block selection. */
PickedPos Game_SelectedPos;
/* Picked pos instance used for camera clipping. */
PickedPos Game_CameraClipPos;
/* Default index buffer ID. */
Int32 Game_DefaultIb;
/* Whether cobblestone slab to stone brick tiles should be used. */
bool Game_UseCPEBlocks;
/* Account username of the player.*/
String Game_Username;
/* Verification key used for multiplayer, unique for the username and individual server. */
String Game_Mppass;
/* IP address of multiplayer server connected to, null if singleplayer. */
String Game_IPAddress;
/* Port of multiplayer server connected to, 0 if singleplayer. */
Int32 Game_Port;
/* Radius of the sphere the player can see around the position of the current camera. */
Real32 Game_ViewDistance;
/* Maximum view distance player can view up to. */
Real32 Game_MaxViewDistance;
/* 'Real' view distance the player has selected. */
Real32 Game_UserViewDistance;
/* Field of view for the current camera in degrees. */
Int32 Game_Fov;
Int32 Game_DefaultFov, Game_ZoomFov;
/* Strategy used to limit how many frames should be displayed at most each second. */
FpsLimitMethod FpsLimit;
/* Whether lines should be rendered for each axis. */
bool Game_ShowAxisLines;
/* Whether players should animate using simple swinging parallel to their bodies. */
bool Game_SimpleArmsAnim;
/* Whether the arm model should use the classic position. */
bool Game_ClassicArmModel;
/* Whether mouse rotation on the y axis should be inverted. */
bool Game_InvertMouse;
/* Number of vertices used for rendering terrain this frame. */
Int32 Game_Vertices;
/* Model view matrix. */
Matrix Game_View;
/* Projection matrix. */
Matrix Game_Projection;
/* How sensitive the client is to changes in the player's mouse position. */
Int32 Game_MouseSensitivity;
/* Whether tab names autocomplete. */
bool Game_TabAutocomplete;
bool Game_UseClassicGui;
bool Game_UseClassicTabList;
bool Game_UseClassicOptions;
bool Game_ClassicMode;
bool Game_ClassicHacks;
#define Game_PureClassic (Game_ClassicMode && !Game_ClassicHacks)
/* Whether suport for custom blocks is indicated to the server. */
bool Game_AllowCustomBlocks;
/* Whether CPE is used at all. */
bool Game_UseCPE;
/* Whether all texture packs are ignored from the server or not. */
bool Game_AllowServerTextures;
/* Whether advanced/smooth lighting mesh builder is used. */
bool Game_SmoothLighting;
/* Whether chat logging to disc is enabled. */
bool Game_ChatLogging;
/* Whether auto rotation of blocks with special suffixes is enabled. */
bool Game_AutoRotate;
/* Whether camera has smooth rotation. */
bool Game_SmoothCamera;
/* Font name used for text rendering. */
String Game_FontName;
/* Max number of chatlines drawn in chat. */
Int32 Game_ChatLines;
/* Whether clicking on chatlines copies into chat input is enabled. */
bool Game_ClickableChat;
/* Whether the GUI is completely hidden.*/
bool Game_HideGui;
/* Whether FPS status in top left is hidden. */
bool Game_ShowFPS;
/* Raw hotbar scale.*/
static Real32 Game_RawHotbarScale;
/* Raw chat scale. */
static Real32 Game_RawChatScale;
/* Raw inventory scale*/
static Real32 Game_RawInventoryScale;
/* Whether view bobbing is enabled. */
bool Game_ViewBobbing;
/* Whether block in hand is shown in bottom right. */
bool Game_ShowBlockInHand;
/* Volume of dig and step sounds. 0 means disabled. */
Int32 Game_SoundsVolume;
/* Volume of background music played. 0 means disabled */
Int32 Game_MusicVolume;
/* Whether water/lava can be placed/deleted like normal blocks. */
bool Game_ModifiableLiquids;
/* Current position of the camera. */
Vector3 Game_CurrentCameraPos;
/* Whether a screenshot is requested. */
bool Game_ScreenshotRequested;
/* Calculates the amount that the hotbar widget should be scaled by when rendered.
Affected by current resolution of the window, as scaling specified by the user */
Real32 Game_GetGuiHotbarScale(void);
/* Calculates the amount that the block inventory menu should be scaled by when rendered.
Affected by current resolution of the window, and scaling specified by the user */
Real32 Game_GetGuiInventoryScale(void);
/* alculates the amount that 2D chat widgets should be scaled by when rendered.
Affected by current resolution of the window, and scaling specified by the user*/
Real32 Game_GetGuiChatScale(void);
/* Gets path of default texture pack path.
NOTE: If texture pack specified by user can't be found, returns 'default.zip' */
String Game_GetDefaultTexturePack(void);
/* Sets the default texture pack path. */
void Game_SetDefaultTexturePack(String value);
static bool Game_CursorVisible;
static bool Game_realCursorVisible;
/* Sets whether the cursor is visible. */
void Game_SetCursorVisible(bool visible);
/* Called when projection matrix is updated. */
void Game_UpdateProjection(void);

View File

@ -1,170 +0,0 @@
#ifndef CS_GAMEPROPS_H
#define CS_GAMEPROPS_H
#include "Typedefs.h"
#include "Options.h"
#include "String.h"
#include "PickedPos.h"
#include "Vectors.h"
/* Total rendering time(in seconds) elapsed since the client was started. */
Real64 Game_Accumulator;
/* Accumulator for the number of chunk updates performed. Reset every second. */
Int32 Game_ChunkUpdates;
/* Whether the third person camera should have their camera position clipped so as to not intersect blocks.*/
bool Game_CameraClipping;
/* Whether colour clear gfx call should be skipped. */
bool Game_SkipClear;
/* Picked pos instance used for block selection. */
PickedPos Game_SelectedPos;
/* Picked pos instance used for camera clipping. */
PickedPos Game_CameraClipPos;
/* Default index buffer ID. */
Int32 Game_DefaultIb;
/* Whether cobblestone slab to stone brick tiles should be used. */
bool Game_UseCPEBlocks;
/* Account username of the player.*/
String Game_Username;
/* Verification key used for multiplayer, unique for the username and individual server. */
String Game_Mppass;
/* IP address of multiplayer server connected to, null if singleplayer. */
String Game_IPAddress;
/* Port of multiplayer server connected to, 0 if singleplayer. */
Int32 Game_Port;
/* Radius of the sphere the player can see around the position of the current camera. */
Real32 Game_ViewDistance;
/* Maximum view distance player can view up to. */
Real32 Game_MaxViewDistance;
/* 'Real' view distance the player has selected. */
Real32 Game_UserViewDistance;
/* Field of view for the current camera in degrees. */
Int32 Game_Fov;
Int32 Game_DefaultFov, Game_ZoomFov;
/* Strategy used to limit how many frames should be displayed at most each second. */
FpsLimitMethod FpsLimit;
/* Whether lines should be rendered for each axis. */
bool Game_ShowAxisLines;
/* Whether players should animate using simple swinging parallel to their bodies. */
bool Game_SimpleArmsAnim;
/* Whether the arm model should use the classic position. */
bool Game_ClassicArmModel;
/* Whether mouse rotation on the y axis should be inverted. */
bool Game_InvertMouse;
/* Number of vertices used for rendering terrain this frame. */
Int32 Game_Vertices;
/* Model view matrix. */
Matrix Game_View;
/* Projection matrix. */
Matrix Game_Projection;
/* How sensitive the client is to changes in the player's mouse position. */
Int32 Game_MouseSensitivity;
/* Whether tab names autocomplete. */
bool Game_TabAutocomplete;
bool Game_UseClassicGui;
bool Game_UseClassicTabList;
bool Game_UseClassicOptions;
bool Game_ClassicMode;
bool Game_ClassicHacks;
#define Game_PureClassic (Game_ClassicMode && !Game_ClassicHacks)
/* Whether suport for custom blocks is indicated to the server. */
bool Game_AllowCustomBlocks;
/* Whether CPE is used at all. */
bool Game_UseCPE;
/* Whether all texture packs are ignored from the server or not. */
bool Game_AllowServerTextures;
/* Whether advanced/smooth lighting mesh builder is used. */
bool Game_SmoothLighting;
/* Whether chat logging to disc is enabled. */
bool Game_ChatLogging;
/* Whether auto rotation of blocks with special suffixes is enabled. */
bool Game_AutoRotate;
/* Whether camera has smooth rotation. */
bool Game_SmoothCamera;
/* Font name used for text rendering. */
String Game_FontName;
/* Max number of chatlines drawn in chat. */
Int32 Game_ChatLines;
/* Whether clicking on chatlines copies into chat input is enabled. */
bool Game_ClickableChat;
/* Whether the GUI is completely hidden.*/
bool Game_HideGui;
/* Whether FPS status in top left is hidden. */
bool Game_ShowFPS;
/* Raw hotbar scale.*/
static Real32 Game_RawHotbarScale;
/* Raw chat scale. */
static Real32 Game_RawChatScale;
/* Raw inventory scale*/
static Real32 Game_RawInventoryScale;
/* Whether view bobbing is enabled. */
bool Game_ViewBobbing;
/* Whether block in hand is shown in bottom right. */
bool Game_ShowBlockInHand;
/* Volume of dig and step sounds. 0 means disabled. */
Int32 Game_SoundsVolume;
/* Volume of background music played. 0 means disabled */
Int32 Game_MusicVolume;
/* Whether water/lava can be placed/deleted like normal blocks. */
bool Game_ModifiableLiquids;
/* Current position of the camera. */
Vector3 Game_CurrentCameraPos;
/* Whether a screenshot is requested. */
bool Game_ScreenshotRequested;
/* Calculates the amount that the hotbar widget should be scaled by when rendered.
Affected by current resolution of the window, as scaling specified by the user */
Real32 Game_GetGuiHotbarScale(void);
/* Calculates the amount that the block inventory menu should be scaled by when rendered.
Affected by current resolution of the window, and scaling specified by the user */
Real32 Game_GetGuiInventoryScale(void);
/* alculates the amount that 2D chat widgets should be scaled by when rendered.
Affected by current resolution of the window, and scaling specified by the user*/
Real32 Game_GetGuiChatScale(void);
/* Gets path of default texture pack path.
NOTE: If texture pack specified by user can't be found, returns 'default.zip' */
String Game_GetDefaultTexturePack(void);
/* Sets the default texture pack path. */
void Game_SetDefaultTexturePack(String value);
static bool Game_CursorVisible;
static bool Game_realCursorVisible;
/* Sets whether the cursor is visible. */
void Game_SetCursorVisible(bool visible);
#endif

View File

@ -8,7 +8,6 @@ typedef Int32 VertexFormat;
#define VertexFormat_P3fC4b 0
#define VertexFormat_P3fT2fC4b 1
/* 3D graphics pixel comparison functions */
typedef Int32 CompareFunc;
#define CompareFunc_Always 0
@ -20,7 +19,6 @@ typedef Int32 CompareFunc;
#define CompareFunc_GreaterEqual 6
#define CompareFunc_Greater 7
/* 3D graphics pixel blending functions */
typedef Int32 BlendFunc;
#define BlendFunc_Zero 0
@ -30,14 +28,12 @@ typedef Int32 BlendFunc;
#define BlendFunc_DestAlpha 4
#define BlendFunc_InvDestAlpha 5
/* 3D graphics pixel fog blending functions */
typedef Int32 Fog;
#define Fog_Linear 0
#define Fog_Exp 1
#define Fog_Exp2 2
/* 3D graphics matrix types */
typedef Int32 MatrixType;
#define MatrixType_Projection 0

View File

@ -1,8 +1,7 @@
#if 0
#include "IModel.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "GameProps.h"
#include "Game.h"
#include "ModelCache.h"
#include "GraphicsCommon.h"
#include "FrustumCulling.h"
@ -23,7 +22,6 @@ void ModelPart_Init(ModelPart* part, Int32 offset, Int32 count, Real32 rotX, Rea
void IModel_Init(IModel* model) {
model->Rotation = RotateOrder_ZYX;
model->Bobbing = true;
model->UsesSkin = true;
model->CalcHumanAnims = false;
@ -41,7 +39,7 @@ void IModel_Init(IModel* model) {
bool IModel_ShouldRender(Entity* entity) {
Vector3 pos = entity->Position;
AABB bb = Entity_GetPickingBounds(entity);
AABB bb; Entity_GetPickingBounds(entity, &bb);
AABB* bbPtr = &bb;
Real32 bbWidth = AABB_Width(bbPtr);
@ -285,4 +283,3 @@ void BoxDesc_ZQuad(IModel* m, Int32 texX, Int32 texY, Int32 texWidth, Int32 texH
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++;
}
#endif

View File

@ -1,4 +1,3 @@
#if 0
#ifndef CS_MODEL_H
#define CS_MODEL_H
#include "Typedefs.h"
@ -11,6 +10,7 @@
/* Contains various structs and methods for an entity model.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
typedef struct Entity_ Entity; /* Forward declaration */
#define IModel_QuadVertices 4
#define IModel_BoxVertices (Face_Count * IModel_QuadVertices)
@ -257,4 +257,3 @@ void BoxDesc_YQuad(IModel* m, Int32 texX, Int32 texY, Int32 texWidth, Int32 texH
void BoxDesc_ZQuad(IModel* m, Int32 texX, Int32 texY, Int32 texWidth, Int32 texHeight,
Real32 x1, Real32 x2, Real32 y1, Real32 y2, Real32 z, bool swapU);
#endif
#endif

View File

@ -1,26 +0,0 @@
#if 0
#ifndef CS_LOCALPLAYER_H
#define CS_LOCALPLAYER_H
#include "Typedefs.h"
#include "Player.h"
/* Represents the user/player's own entity.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
typedef struct LocalPlayer_ {
Player Base;
/* Position the player's position is set to when the 'respawn' key binding is pressed. */
Vector3 Spawn;
/* Orientation set to when player respawns.*/
Real32 SpawnRotY, SpawnHeadX;
} LocalPlayer;
/* Singleton instance of the local player. */
LocalPlayer LocalPlayer_Instance;
/* Initalises the local player instance. */
void LocalPlayer_Init(void);
#endif

View File

@ -5,11 +5,10 @@
#include "Events.h"
#include "String.h"
String ModelCache_charPngString;
String ModelCache_charPngString = String_FromConstant("char.png");
Int32 ModelCache_texCount, ModelCache_modelCount;
void ModelCache_Init(void) {
ModelCache_charPngString = String_FromConstant("char.png");
ModelCache_RegisterDefaultModels();
ModelCache_ContextRecreated();
@ -27,8 +26,8 @@ void ModelCache_Free(void) {
ModelCache_ContextLost();
Event_UnregisterStream(&TextureEvents_FileChanged, ModelCache_TextureChanged);
Event_UnregisterVoid(&Gfx_ContextLost, ModelCache_ContextLost);
Event_UnregisterVoid(&Gfx_ContextRecreated, ModelCache_ContextRecreated);
Event_UnregisterVoid(&GfxEvents_ContextLost, ModelCache_ContextLost);
Event_UnregisterVoid(&GfxEvents_ContextRecreated, ModelCache_ContextRecreated);
}

View File

@ -1,4 +1,3 @@
#if 0
#ifndef CS_MODELCACHE_H
#define CS_MODELCACHE_H
#include "Typedefs.h"
@ -81,4 +80,3 @@ static void ModelCache_ContextLost(void);
static void ModelCache_ContextRecreated(void);
#endif
#endif

View File

@ -1,4 +1,3 @@
#if 0
#ifndef CS_OPTIONS_H
#define CS_OPTIONS_H
#include "Typedefs.h"
@ -69,4 +68,3 @@ typedef UInt8 FpsLimitMethod;
#define OptionsKey_AllowClassicHacks "nostalgia-hacks"
#define OptionsKey_ClassicArmModel "nostalgia-classicarm"
#endif
#endif

View File

@ -1,37 +1,29 @@
#if 0
#ifndef CS_PICKEDPOS_H
#define CS_PICKEDPOS_H
#include "Typedefs.h"
#include "Constants.h"
#include "Vectors.h"
#include "Block.h"
#include "BlockID.h"
/* Data for picked/selected block by the user, and related methods.
Copyright 2014 - 2017 ClassicalSharp | Licensed under BSD-3
*/
/* Describes the picked/selected block by the user and its position. */
typedef struct PickedPos_ {
/* Minimum world coordinates of the block's bounding box.*/
Vector3 Min;
/* Maximum world coordinates of the block's bounding box. */
Vector3 Max;
/* Exact world coordinates at which the ray intersected this block. */
Vector3 Intersect;
/* Integer world coordinates of the block. */
Vector3I BlockPos;
/* Integer world coordinates of the neighbouring block that is closest to the player. */
Vector3I TranslatedPos;
/* Whether this instance actually has a selected block currently. */
bool Valid;
/* Face of the picked block that is closet to the player. */
Face ClosestFace;
/* Block ID of the picked block. */
BlockID Block;
} PickedPos;
@ -41,7 +33,4 @@ void PickedPos_SetAsValid(PickedPos* pos, Int32 x, Int32 y, Int32 z, Vector3 min
/* Marks as not having a selected block. */
void PickedPos_SetAsInvalid(PickedPos* pos);
static void PickedPos_TestAxis(Real32 dAxis, Real32* dist, Face face);
#endif
#endif

View File

@ -1,4 +1,3 @@
#if 0
#ifndef CS_PLAYER_H
#define CS_PLAYER_H
#include "Typedefs.h"
@ -7,7 +6,24 @@
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Represents a player entity. */
typedef struct Player_ {
Entity Base;
} Player;
/* Represents the user/player's own entity. */
typedef struct LocalPlayer_ {
Player Base;
/* Position the player's position is set to when the 'respawn' key binding is pressed. */
Vector3 Spawn;
/* Orientation set to when player respawns.*/
Real32 SpawnRotY, SpawnHeadX;
} LocalPlayer;
/* Singleton instance of the local player. */
LocalPlayer LocalPlayer_Instance;
/* Initalises the local player instance. */
void LocalPlayer_Init(void);
#endif

View File

@ -1,32 +1,3 @@
#if 0
#include "TiltComp.h"
#include "AnimatedComp.h"
#include "ExtMath.h"
#include "GameProps.h"
#include "LocalPlayer.h"
void TiltComp_Init(TiltComp* anim) {
anim->TiltX = 0.0f; anim->TiltY = 0.0f; anim->VelTiltStrength = 1.0f;
anim->VelTiltStrengthO = 1.0f; anim->VelTiltStrengthN = 1.0f;
}
void TiltComp_Update(TiltComp* anim, Real64 delta) {
anim->VelTiltStrengthO = anim->VelTiltStrengthN;
LocalPlayer* p = &LocalPlayer_Instance;
/* TODO: the Tilt code was designed for 60 ticks/second, fix it up for 20 ticks/second */
Int32 i;
for (i = 0; i < 3; i++) {
AnimatedComp_DoTilt(&anim->VelTiltStrengthN, p->Hacks.Noclip || p->Hacks.Flying);
}
}
void TiltComp_GetCurrent(TiltComp* anim, Real32 t) {
LocalPlayer* p = &LocalPlayer_Instance;
anim->VelTiltStrength = Math_Lerp(anim->VelTiltStrengthO, anim->VelTiltStrengthN, t);
AnimatedComp* pAnim = &p->Base.Base.Anim;
anim->TiltX = Math_Cos(pAnim->WalkTime) * pAnim->Swing * (0.15f * MATH_DEG2RAD);
anim->TiltY = Math_Sin(pAnim->WalkTime) * pAnim->Swing * (0.15f * MATH_DEG2RAD);
}
#endif

View File

@ -1,25 +0,0 @@
#if 0
#ifndef CS_TILTCOMP_H
#define CS_TILTCOMP_H
#include "Typedefs.h"
#include "Entity.h"
/* Entity component that performs tilt animation depending on movement speed and time.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Stores variables for performing tilt animation. */
typedef struct TiltComp_ {
Real32 TiltX, TiltY, VelTiltStrength;
Real32 VelTiltStrengthO, VelTiltStrengthN;
} TiltComp;
/* Initalises default values for a tilt component. */
void TiltComp_Init(TiltComp* anim);
/* Calculates the next tilt animation state. */
void TiltComp_Update(TiltComp* anim, Real64 delta);
/* Calculates the interpolated state between the last and next tilt animation state. */
void TiltComp_GetCurrent(TiltComp* anim, Real32 t);
#endif

View File

@ -40,6 +40,8 @@ typedef UInt8 bool;
typedef UInt8 BlockID;
typedef UInt8 EntityID;
typedef UInt8 TextureLoc;
/* Sides of a block. TODO: Map this to CPE PlayerClicked blockface enums. */
typedef UInt8 Face;
#define UInt8_MaxValue ((UInt8)0xFF)
#define Int16_MaxValue ((Int16)0x7FFF)

View File

@ -1,4 +1,3 @@
#if 0
#include "World.h"
#include "BlockID.h"
#include "ErrorHandler.h"
@ -209,4 +208,3 @@ void WorldEnv_SetShadowCol(PackedCol col) {
&WorldEnv_ShadowZSide, &WorldEnv_ShadowYBottom);
Event_RaiseInt32(&WorldEvents_EnvVarChanged, EnvVar_ShadowCol);
}
#endif

View File

@ -1,9 +1,9 @@
#if 0
#ifndef CS_WORLD_H
#define CS_WORLD_H
#include "Typedefs.h"
#include "String.h"
#include "Vectors.h"
#include "PackedCol.h"
/* Represents a fixed size 3D array of blocks.
Also contains associated environment metadata.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
@ -214,4 +214,3 @@ void WorldEnv_SetSunCol(PackedCol col);
/* Sets shadow colour, and raises event with variable 'ShadowCol'. */
void WorldEnv_SetShadowCol(PackedCol col);
#endif
#endif