mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-24 05:10:42 -04:00
Merge branch 'master' of github.com:UnknownShadow200/ClassicalSharp
This commit is contained in:
commit
91082328fc
@ -31,7 +31,7 @@ namespace ClassicalSharp.Gui {
|
||||
|
||||
MakeOpt( -1, 0, "Jump height", OnWidgetClick,
|
||||
g => g.LocalPlayer.JumpHeight.ToString( "F3" ),
|
||||
(g, v) => g.LocalPlayer.physics.CalculateJumpVelocity( Single.Parse( v ) ) ),
|
||||
(g, v) => g.LocalPlayer.physics.CalculateJumpVelocity( true, Single.Parse( v ) ) ),
|
||||
|
||||
MakeBool( -1, 50, "Double jump", OptionsKey.DoubleJump,
|
||||
OnWidgetClick, g => g.LocalPlayer.Hacks.DoubleJump,
|
||||
|
@ -70,6 +70,8 @@ namespace ClassicalSharp.Entities {
|
||||
/// <summary> Whether the player is currently walking at base speed * 0.5 * speed multiplier. </summary>
|
||||
public bool HalfSpeeding;
|
||||
|
||||
public bool CanJumpHigher { get { return Enabled && CanAnyHacks && CanSpeed; } }
|
||||
|
||||
/// <summary> Parses hack flags specified in the motd and/or name of the server. </summary>
|
||||
/// <remarks> Recognises +/-hax, +/-fly, +/-noclip, +/-speed, +/-respawn, +/-ophax, and horspeed=xyz </remarks>
|
||||
public void ParseHackFlags( string name, string motd ) {
|
||||
|
@ -13,7 +13,8 @@ namespace ClassicalSharp.Entities {
|
||||
Entity entity;
|
||||
Game game;
|
||||
BlockInfo info;
|
||||
internal float jumpVel = 0.42f, serverJumpVel = 0.42f;
|
||||
|
||||
internal float jumpVel = 0.42f, userJumpVel = 0.42f, serverJumpVel = 0.42f;
|
||||
internal HacksComponent hacks;
|
||||
internal CollisionsComponent collisions;
|
||||
|
||||
@ -233,7 +234,7 @@ namespace ClassicalSharp.Entities {
|
||||
|
||||
/// <summary> Calculates the jump velocity required such that when a client presses
|
||||
/// the jump binding they will be able to jump up to the given height. </summary>
|
||||
internal void CalculateJumpVelocity( float jumpHeight ) {
|
||||
internal void CalculateJumpVelocity( bool userVel, float jumpHeight ) {
|
||||
jumpVel = 0;
|
||||
if( jumpHeight >= 256 ) jumpVel = 10.0f;
|
||||
if( jumpHeight >= 512 ) jumpVel = 16.5f;
|
||||
@ -241,6 +242,7 @@ namespace ClassicalSharp.Entities {
|
||||
|
||||
while( GetMaxHeight( jumpVel ) <= jumpHeight )
|
||||
jumpVel += 0.001f;
|
||||
if( userVel ) userJumpVel = jumpVel;
|
||||
}
|
||||
|
||||
public static double GetMaxHeight( float u ) {
|
||||
|
@ -106,7 +106,7 @@ namespace ClassicalSharp.Entities {
|
||||
/// <summary> Disables any hacks if their respective CanHackX value is set to false. </summary>
|
||||
public void CheckHacksConsistency() {
|
||||
Hacks.CheckHacksConsistency();
|
||||
if( !Hacks.Enabled || !Hacks.CanAnyHacks || !Hacks.CanSpeed )
|
||||
if( !Hacks.CanJumpHigher )
|
||||
physics.jumpVel = physics.serverJumpVel;
|
||||
}
|
||||
|
||||
|
@ -299,8 +299,10 @@ namespace ClassicalSharp.Network {
|
||||
p.CheckHacksConsistency();
|
||||
|
||||
float jumpHeight = reader.ReadInt16() / 32f;
|
||||
if( jumpHeight < 0 ) p.physics.jumpVel = 0.42f;
|
||||
else p.physics.CalculateJumpVelocity( jumpHeight );
|
||||
if( jumpHeight < 0 )
|
||||
p.physics.jumpVel = p.Hacks.CanJumpHigher ? p.physics.userJumpVel : 0.42f;
|
||||
else
|
||||
p.physics.CalculateJumpVelocity( false, jumpHeight );
|
||||
p.physics.serverJumpVel = p.physics.jumpVel;
|
||||
game.Events.RaiseHackPermissionsChanged();
|
||||
}
|
||||
|
@ -12,26 +12,19 @@ namespace ClassicalSharp.Renderers {
|
||||
Vector3I newChunkPos = Vector3I.Floor( cameraPos );
|
||||
newChunkPos.X = (newChunkPos.X & ~0x0F) + 8;
|
||||
newChunkPos.Y = (newChunkPos.Y & ~0x0F) + 8;
|
||||
newChunkPos.Z = (newChunkPos.Z & ~0x0F) + 8;
|
||||
newChunkPos.Z = (newChunkPos.Z & ~0x0F) + 8;
|
||||
if( newChunkPos == updater.chunkPos ) return;
|
||||
|
||||
ChunkInfo[] chunks = game.MapRenderer.chunks;
|
||||
int[] distances = updater.distances;
|
||||
updater.chunkPos = newChunkPos;
|
||||
|
||||
for( int i = 0; i < distances.Length; i++ ) {
|
||||
ChunkInfo info = chunks[i];
|
||||
distances[i] = Utils.DistanceSquared( info.CentreX, info.CentreY, info.CentreZ,
|
||||
updater.chunkPos.X, updater.chunkPos.Y, updater.chunkPos.Z );
|
||||
}
|
||||
|
||||
// NOTE: Over 5x faster compared to normal comparison of IComparer<ChunkInfo>.Compare
|
||||
if( distances.Length > 1 )
|
||||
QuickSort( distances, chunks, 0, chunks.Length - 1 );
|
||||
|
||||
int[] distances = updater.distances;
|
||||
Vector3I pPos = newChunkPos;
|
||||
updater.chunkPos = pPos;
|
||||
|
||||
for( int i = 0; i < chunks.Length; i++ ) {
|
||||
ChunkInfo info = chunks[i];
|
||||
distances[i] = Utils.DistanceSquared( info.CentreX, info.CentreY, info.CentreZ,
|
||||
pPos.X, pPos.Y, pPos.Z );
|
||||
|
||||
int dX1 = (info.CentreX - 8) - pPos.X, dX2 = (info.CentreX + 8) - pPos.X;
|
||||
int dY1 = (info.CentreY - 8) - pPos.Y, dY2 = (info.CentreY + 8) - pPos.Y;
|
||||
int dZ1 = (info.CentreZ - 8) - pPos.Z, dZ2 = (info.CentreZ + 8) - pPos.Z;
|
||||
@ -44,6 +37,10 @@ namespace ClassicalSharp.Renderers {
|
||||
info.DrawBottom = !(dY1 <= 0 && dY2 <= 0);
|
||||
info.DrawTop = !(dY1 >= 0 && dY2 >= 0);
|
||||
}
|
||||
|
||||
// NOTE: Over 5x faster compared to normal comparison of IComparer<ChunkInfo>.Compare
|
||||
if( distances.Length > 1 )
|
||||
QuickSort( distances, chunks, 0, chunks.Length - 1 );
|
||||
updater.ResetUsedFlags();
|
||||
//SimpleOcclusionCulling();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user