more WIP with vorbis

This commit is contained in:
UnknownShadow200 2018-07-30 21:13:01 +10:00
parent 12a823cc8e
commit ae764cf2be
17 changed files with 670 additions and 508 deletions

View File

@ -1,6 +1,5 @@
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
using System;
using ClassicalSharp.Model;
using ClassicalSharp.Physics;
using OpenTK;
using BlockID = System.UInt16;

View File

@ -3,9 +3,6 @@ using System;
using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using OpenTK;
#if ANDROID
using Android.Graphics;
#endif
using BlockID = System.UInt16;
namespace ClassicalSharp.Entities {

View File

@ -2,7 +2,6 @@
using System;
using System.Drawing;
using ClassicalSharp.Physics;
using ClassicalSharp.Renderers;
using OpenTK;
using OpenTK.Input;
using BlockID = System.UInt16;

View File

@ -3,7 +3,6 @@ using System;
using ClassicalSharp.Entities;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Physics;
using ClassicalSharp.Renderers;
using ClassicalSharp.Textures;
using OpenTK;
using BlockID = System.UInt16;

View File

@ -1,7 +1,6 @@
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
using System;
using ClassicalSharp.Entities;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Physics;
using OpenTK;

View File

@ -1,7 +1,6 @@
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
using System;
using ClassicalSharp.Entities;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Physics;
using OpenTK;

View File

@ -1,18 +1,11 @@
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
using System;
using System.Drawing;
using System.IO;
using System.Net;
using ClassicalSharp.Entities;
using ClassicalSharp.Generator;
using ClassicalSharp.Gui.Screens;
using ClassicalSharp.Network;
using ClassicalSharp.Textures;
using OpenTK;
using OpenTK.Input;
#if ANDROID
using Android.Graphics;
#endif
namespace ClassicalSharp {
@ -20,21 +13,14 @@ namespace ClassicalSharp {
public abstract class IServerConnection : IGameComponent {
public bool IsSinglePlayer;
/// <summary> Opens a connection to the server, and prepares the initial state of the client. </summary>
public bool Disconnected;
public abstract void BeginConnect();
public abstract void Tick(ScheduledTask task);
public abstract void SendChat(string text);
/// <summary> Informs the server of the client's current position and orientation. </summary>
public abstract void SendPosition(Vector3 pos, float rotY, float headX);
/// <summary> Informs the server that using the given mouse button,
/// the client clicked on a particular block or entity. </summary>
public abstract void SendPlayerClick(MouseButton button, bool buttonDown, byte targetId, PickedPos pos);
public abstract void Tick(ScheduledTask task);
public virtual void Init(Game game) { }
public virtual void Ready(Game game) { }
public virtual void OnNewMapLoaded(Game game) { }
@ -47,22 +33,11 @@ namespace ClassicalSharp {
public string ServerMotd;
public string AppName = Program.AppName;
/// <summary> Whether the network processor is currently connected to a server. </summary>
public bool Disconnected;
/// <summary> Whether the client should use extended player list management, with group names and ranks. </summary>
public bool UsingExtPlayerList;
/// <summary> Whether the server supports handling PlayerClick packets from the client. </summary>
public bool UsingPlayerClick;
/// <summary> Whether the server can handle partial message packets or not. </summary>
public bool SupportsPartialMessages;
/// <summary> Whether the server supports receiving all code page 437 characters from this client. </summary>
public bool SupportsFullCP437;
protected Game game;
protected int netTicks;

View File

@ -1,18 +1,12 @@
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
using System;
using System.Drawing;
using System.IO;
using System.Net;
using System.Net.Sockets;
using ClassicalSharp.Entities;
using ClassicalSharp.Events;
using ClassicalSharp.Gui;
using ClassicalSharp.Network;
using ClassicalSharp.Textures;
using ClassicalSharp.Network.Protocols;
using BlockID = System.UInt16;
using OpenTK;
using OpenTK.Input;
using BlockID = System.UInt16;
namespace ClassicalSharp.Network {

View File

@ -3,7 +3,6 @@ using System;
using System.Drawing;
using ClassicalSharp.Entities;
using OpenTK;
using OpenTK.Input;
namespace ClassicalSharp {

File diff suppressed because it is too large Load Diff

View File

@ -34,8 +34,10 @@ struct VorbisState {
UInt32 NumBits; /* Number of bits in Bits buffer*/
struct Stream* Source; /* Source for filling Input buffer */
UInt8 Channels, ModeNumBits; UInt16 CurBlockSize;
UInt8 Channels, ModeNumBits;
UInt16 CurBlockSize, DataSize;
Int32 SampleRate; Int32 BlockSizes[2];
Real32* Values;
struct Codebook* Codebooks;
struct Floor* Floors;
@ -45,4 +47,5 @@ struct VorbisState {
};
void Vorbis_Init(struct VorbisState* state, struct Stream* source);
ReturnCode Vorbis_DecodeHeaders(struct VorbisState* state);
ReturnCode Vorbis_DecodeFrame(struct VorbisState* state);
#endif

View File

@ -306,8 +306,8 @@ void Gfx_SetFogDensity(Real32 value) {
if (value == d3d9_fogDensity) return;
d3d9_fogDensity = value;
if (Gfx_LostContext) return;
IntAndFloat raw; raw.fVal = value;
D3D9_SetRenderState(D3DRS_FOGDENSITY, raw.uVal, "D3D9_SetFogDensity");
union IntAndFloat raw; raw.f = value;
D3D9_SetRenderState(D3DRS_FOGDENSITY, raw.u, "D3D9_SetFogDensity");
}
Real32 d3d9_fogEnd = -1.0f;
@ -315,8 +315,8 @@ void Gfx_SetFogEnd(Real32 value) {
if (value == d3d9_fogEnd) return;
d3d9_fogEnd = value;
if (Gfx_LostContext) return;
IntAndFloat raw; raw.fVal = value;
D3D9_SetRenderState(D3DRS_FOGEND, raw.uVal, "D3D9_SetFogEnd");
union IntAndFloat raw; raw.f = value;
D3D9_SetRenderState(D3DRS_FOGEND, raw.u, "D3D9_SetFogEnd");
}
D3DFOGMODE d3d9_fogTableMode = D3DFOG_NONE;
@ -636,7 +636,7 @@ static void D3D9_SetDefaultRenderStates(void) {
}
static void D3D9_RestoreRenderStates(void) {
IntAndFloat raw;
union IntAndFloat raw;
D3D9_SetRenderState(D3DRS_ALPHATESTENABLE, d3d9_alphaTest, "D3D9_AlphaTest");
D3D9_SetRenderState2(D3DRS_ALPHABLENDENABLE, d3d9_alphaBlend, "D3D9_AlphaBlend");
D3D9_SetRenderState2(D3DRS_ALPHAFUNC, d3d9_alphaTestFunc, "D3D9_AlphaTestFunc");
@ -645,10 +645,10 @@ static void D3D9_RestoreRenderStates(void) {
D3D9_SetRenderState2(D3DRS_DESTBLEND, d3d9_dstBlendFunc, "D3D9_AlphaDstBlend");
D3D9_SetRenderState2(D3DRS_FOGENABLE, d3d9_fogEnable, "D3D9_Fog");
D3D9_SetRenderState2(D3DRS_FOGCOLOR, d3d9_fogCol, "D3D9_FogColor");
raw.fVal = d3d9_fogDensity;
D3D9_SetRenderState2(D3DRS_FOGDENSITY, raw.uVal, "D3D9_FogDensity");
raw.fVal = d3d9_fogEnd;
D3D9_SetRenderState2(D3DRS_FOGEND, raw.uVal, "D3D9_FogEnd");
raw.f = d3d9_fogDensity;
D3D9_SetRenderState2(D3DRS_FOGDENSITY, raw.u, "D3D9_FogDensity");
raw.f = d3d9_fogEnd;
D3D9_SetRenderState2(D3DRS_FOGEND, raw.u, "D3D9_FogEnd");
D3D9_SetRenderState2(D3DRS_FOGTABLEMODE, d3d9_fogTableMode, "D3D9_FogMode");
D3D9_SetRenderState2(D3DRS_ZFUNC, d3d9_depthTestFunc, "D3D9_DepthTestFunc");
D3D9_SetRenderState2(D3DRS_ZENABLE, d3d9_depthTest, "D3D9_DepthTest");

View File

@ -822,9 +822,9 @@ static void Cw_WriteBlockDefinitionCompound(struct Stream* stream, BlockID id) {
Nbt_WriteTag(stream, NBT_TAG_INT8, "CollideType");
Nbt_WriteU8(stream, Block_Collide[id]);
IntAndFloat speed; speed.fVal = Block_SpeedMultiplier[id];
union IntAndFloat speed; speed.f = Block_SpeedMultiplier[id];
Nbt_WriteTag(stream, NBT_TAG_REAL32, "Speed");
Nbt_WriteI32(stream, speed.iVal);
Nbt_WriteI32(stream, speed.i);
Nbt_WriteTag(stream, NBT_TAG_INT8_ARRAY, "Textures");
Nbt_WriteI32(stream, 6);

View File

@ -9,7 +9,7 @@
#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))
#define Array_Elems(arr) (sizeof(arr) / sizeof(arr[0]))
typedef union IntAndFloat_ { Real32 fVal; Int32 iVal; UInt32 uVal; } IntAndFloat;
union IntAndFloat { Real32 f; Int32 i; UInt32 u; };
#define QuickSort_Swap_Maybe()\
if (i <= j) {\

View File

@ -29,6 +29,7 @@ int main(void) {
struct VorbisState state;
Vorbis_Init(&state, &ogg);
Vorbis_DecodeHeaders(&state);
Vorbis_DecodeFrame(&state);
/*Platform_HttpInit();
AsyncRequest req = { 0 };

View File

@ -65,6 +65,7 @@ void PingList_Update(UInt16 data);
Int32 PingList_AveragePingMs(void);
bool ServerConnection_IsSinglePlayer;
bool ServerConnection_Disconnected;
extern String ServerConnection_ServerName;
extern String ServerConnection_ServerMOTD;
extern String ServerConnection_AppName;
@ -77,15 +78,9 @@ void (*ServerConnection_Tick)(struct ScheduledTask* task);
struct Stream* (*ServerConnection_ReadStream)(void);
struct Stream* (*ServerConnection_WriteStream)(void);
/* Whether the network processor is currently disconnected from the server. */
bool ServerConnection_Disconnected;
/* Whether the client supports extended player list management, with group names and ranks. */
bool ServerConnection_SupportsExtPlayerList;
/* Whether the server supports handling PlayerClick packets from the client. */
bool ServerConnection_SupportsPlayerClick;
/* Whether the server can handle partial message packets or not. */
bool ServerConnection_SupportsPartialMessages;
/* Whether the server supports receiving all code page 437 characters from this client. */
bool ServerConnection_SupportsFullCP437;
void ServerConnection_RetrieveTexturePack(STRING_PURE String* url);