Better indentation

This commit is contained in:
UnknownShadow200 2016-08-30 12:49:24 +10:00
parent fd879b0b00
commit d837e52724
20 changed files with 86 additions and 80 deletions

View File

@ -147,13 +147,14 @@ namespace ClassicalSharp.Gui {
void SetFetchStatus( int progress ) {
lastDownload.Clear();
int index = 0;
if( progress == -2 )
if( progress == -2 ) {
lastDownload.Append( ref index, "&eRetrieving texture pack.." );
else if( progress == -1 )
} else if( progress == -1 ) {
lastDownload.Append( ref index, "&eDownloading texture pack" );
else if( progress >= 0 && progress <= 100 )
} else if( progress >= 0 && progress <= 100 ) {
lastDownload.Append( ref index, "&eDownloading texture pack (&7" )
.AppendNum( ref index, progress ).Append( ref index, "&e%)" );
}
status.SetText( 1, lastDownload.ToString() );
}

View File

@ -41,10 +41,11 @@ namespace ClassicalSharp.Gui {
if( button == MouseButton.Left && mouseX >= TableX - scrollbarWidth && mouseX < TableX ) {
ScrollbarClick( mouseY );
} else if( button == MouseButton.Left ) {
if( selIndex != -1 )
if( selIndex != -1 ) {
game.Inventory.HeldBlock = blocksTable[selIndex];
else if( Contains( TableX, TableY, TableWidth, TableHeight, mouseX, mouseY ) )
} else if( Contains( TableX, TableY, TableWidth, TableHeight, mouseX, mouseY ) ) {
return true;
}
bool hotbar = game.IsKeyDown( Key.AltLeft ) || game.IsKeyDown( Key.AltRight );
if( !hotbar )

View File

@ -162,8 +162,7 @@ namespace ClassicalSharp.Gui {
count += 2;
}
if( lastEnd < line.Length )
count++;
if( lastEnd < line.Length ) count++;
return count;
}

View File

@ -57,11 +57,12 @@ namespace ClassicalSharp.Audio {
chunk.BytesUsed = snd.Data.Length;
chunk.Data = snd.Data;
if( snd.Channels == 1 )
if( snd.Channels == 1 ) {
PlayCurrentSound( monoOutputs );
else if( snd.Channels == 2 )
} else if( snd.Channels == 2 ) {
PlayCurrentSound( stereoOutputs );
}
}
IAudioOutput firstSoundOut;
void PlayCurrentSound( IAudioOutput[] outputs ) {

View File

@ -118,36 +118,38 @@ namespace ClassicalSharp.Entities {
// if we have hit the bottom of a block, we need to change the axis we test first.
if( !hitYMin ) {
if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y )
if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y ) {
ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y )
} else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y ) {
ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
else if( finalBB.Min.X + Adjustment >= blockBB.Max.X )
} else if( finalBB.Min.X + Adjustment >= blockBB.Max.X ) {
ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Max.X - Adjustment <= blockBB.Min.X )
} else if( finalBB.Max.X - Adjustment <= blockBB.Min.X ) {
ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z )
} else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z ) {
ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z )
} else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z ) {
ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
}
continue;
}
// if flying or falling, test the horizontal axes first.
if( finalBB.Min.X + Adjustment >= blockBB.Max.X )
if( finalBB.Min.X + Adjustment >= blockBB.Max.X ) {
ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Max.X - Adjustment <= blockBB.Min.X )
} else if( finalBB.Max.X - Adjustment <= blockBB.Min.X ) {
ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z )
} else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z ) {
ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z )
} else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z ) {
ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y )
} else if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y ) {
ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y )
} else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y ) {
ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
}
}
}
void ClipXMin( ref AABB blockBB, ref AABB entityBB, bool wasOn,
AABB finalBB, ref AABB entityExtentBB, ref Vector3 size ) {

View File

@ -111,11 +111,12 @@ namespace ClassicalSharp.Entities {
}
static void ParseFlag( Action<bool> action, string joined, string flag ) {
if( joined.Contains( "+" + flag ) )
if( joined.Contains( "+" + flag ) ) {
action( true );
else if( joined.Contains( "-" + flag ) )
} else if( joined.Contains( "-" + flag ) ) {
action( false );
}
}
/// <summary> Sets the user type of this user. This is used to control permissions for grass,
/// bedrock, water and lava blocks on servers that don't support CPE block permissions. </summary>

View File

@ -106,9 +106,10 @@ namespace ClassicalSharp.Entities {
/// <summary> Disables any hacks if their respective CanHackX value is set to false. </summary>
public void CheckHacksConsistency() {
Hacks.CheckHacksConsistency();
if( !Hacks.CanJumpHigher )
if( !Hacks.CanJumpHigher ) {
physics.jumpVel = physics.serverJumpVel;
}
}
internal Vector3 lastPos, nextPos;
internal float lastYaw, nextYaw, lastPitch, nextPitch;

View File

@ -5,7 +5,7 @@ namespace ClassicalSharp.Events {
/// <summary> Contains events related to the spawning/despawning of entities,
/// and the creation/removal of tab list entries. </summary>
public sealed class EntityEvents : OtherEvents {
public sealed class EntityEvents : EventsBase {
IdEventArgs idArgs = new IdEventArgs();

View File

@ -3,7 +3,20 @@ using System;
namespace ClassicalSharp.Events {
public class OtherEvents {
public abstract class EventsBase {
protected void Raise( EventHandler handler ) {
if( handler == null ) return;
handler( this, EventArgs.Empty );
}
protected void Raise<T>( EventHandler<T> handler, T args ) where T : EventArgs {
if( handler == null ) return;
handler( this, args );
}
}
public class OtherEvents : EventsBase {
/// <summary> Raised when the terrain atlas ("terrain.png") is changed. </summary>
public event EventHandler TerrainAtlasChanged;
@ -61,15 +74,6 @@ namespace ClassicalSharp.Events {
ChatEventArgs chatArgs = new ChatEventArgs();
TextureEventArgs texArgs = new TextureEventArgs();
ColourCodeEventArgs colArgs = new ColourCodeEventArgs();
protected void Raise( EventHandler handler ) {
if( handler != null )
handler( this, EventArgs.Empty );
}
protected void Raise<T>( EventHandler<T> handler, T args ) where T : EventArgs {
if( handler != null )
handler( this, args );
}
}
public sealed class ChatEventArgs : EventArgs {

View File

@ -3,7 +3,7 @@ using System;
namespace ClassicalSharp.Events {
public class UserEvents {
public class UserEvents : EventsBase {
/// <summary> Raised when the user changes a block in the world. </summary>
public event EventHandler<BlockChangedEventArgs> BlockChanged;
@ -13,15 +13,6 @@ namespace ClassicalSharp.Events {
}
BlockChangedEventArgs blockArgs = new BlockChangedEventArgs();
protected void Raise( EventHandler handler ) {
if( handler != null )
handler( this, EventArgs.Empty );
}
protected void Raise<T>( EventHandler<T> handler, T args ) where T : EventArgs {
if( handler != null )
handler( this, args );
}
}
public sealed class BlockChangedEventArgs : EventArgs {

View File

@ -3,7 +3,7 @@ using System;
namespace ClassicalSharp.Events {
public class WorldEvents : OtherEvents {
public class WorldEvents : EventsBase {
/// <summary> Raised when the player joins and begins loading a new world. </summary>
public event EventHandler OnNewMap;

View File

@ -61,13 +61,14 @@ namespace ClassicalSharp {
}
void TextureChanged( object sender, TextureEventArgs e ) {
if( e.Name == "gui.png" )
if( e.Name == "gui.png" ) {
game.UpdateTexture( ref GuiTex, e.Name, e.Data, false );
else if( e.Name == "gui_classic.png" )
} else if( e.Name == "gui_classic.png" ) {
game.UpdateTexture( ref GuiClassicTex, e.Name, e.Data, false );
else if( e.Name == "icons.png" )
} else if( e.Name == "icons.png" ) {
game.UpdateTexture( ref IconsTex, e.Name, e.Data, false );
}
}
public void SetNewScreen( Screen screen ) { SetNewScreen( screen, true ); }

View File

@ -183,11 +183,12 @@ namespace ClassicalSharp {
bool more;
if( !Hotkeys.IsHotkey( key, game.Keyboard, out text, out more ) ) return;
if( !more )
if( !more ) {
game.Network.SendChat( text, false );
else if( game.Gui.activeScreen == null )
} else if( game.Gui.activeScreen == null ) {
game.Gui.hudScreen.OpenTextInputBar( text );
}
}
MouseButtonEventArgs simArgs = new MouseButtonEventArgs();
bool SimulateMouse( Key key, bool pressed ) {

View File

@ -109,18 +109,19 @@ namespace ClassicalSharp {
Vector3 oldP = game.LocalPlayer.Position;
// Offset position by the closest face
if( selected.BlockFace == CpeBlockFace.XMax )
if( selected.BlockFace == CpeBlockFace.XMax ) {
newP.X = blockBB.Max.X + 0.5f;
else if( selected.BlockFace == CpeBlockFace.ZMax )
} else if( selected.BlockFace == CpeBlockFace.ZMax ) {
newP.Z = blockBB.Max.Z + 0.5f;
else if( selected.BlockFace == CpeBlockFace.XMin )
} else if( selected.BlockFace == CpeBlockFace.XMin ) {
newP.X = blockBB.Min.X - 0.5f;
else if( selected.BlockFace == CpeBlockFace.ZMin )
} else if( selected.BlockFace == CpeBlockFace.ZMin ) {
newP.Z = blockBB.Min.Z - 0.5f;
else if( selected.BlockFace == CpeBlockFace.YMax )
} else if( selected.BlockFace == CpeBlockFace.YMax ) {
newP.Y = blockBB.Min.Y + 1 + Entity.Adjustment;
else if( selected.BlockFace == CpeBlockFace.YMin )
} else if( selected.BlockFace == CpeBlockFace.YMin ) {
newP.Y = blockBB.Min.Y - game.LocalPlayer.Size.Y - Entity.Adjustment;
}
Vector3I newLoc = Vector3I.Floor( newP );
bool validPos = newLoc.X >= 0 && newLoc.Y >= 0 && newLoc.Z >= 0 &&

View File

@ -37,7 +37,7 @@ namespace ClassicalSharp.Generator {
stack.Push( startIndex );
while( stack.Size > 0 ) {
int index = stack.Pop();
if( blocks[index] == 0 ) {
if( blocks[index] != 0 ) continue;
blocks[index] = block;
int x = index % width;
@ -50,7 +50,6 @@ namespace ClassicalSharp.Generator {
if( y > 0 ) stack.Push( index - oneY );
}
}
}
sealed class FastIntStack {
public int[] Values;

View File

@ -61,7 +61,7 @@ namespace ClassicalSharp.Map {
int bx = i & 0xF, by = (i >> 8) & 0xF, bz = (i >> 4) & 0xF;
int index = baseIndex + (by * length + bz) * width + bx;
if( blocks[index] == customTile )
if( blocks[index] != customTile ) continue;
blocks[index] = chunk[i];
}
}

View File

@ -122,8 +122,7 @@ namespace ClassicalSharp.Network {
internal void HandleLevelDataChunk() {
// Workaround for some servers that send LevelDataChunk before LevelInit
// due to their async packet sending behaviour.
if( gzipStream == null )
HandleLevelInit();
if( gzipStream == null ) HandleLevelInit();
int usedLength = reader.ReadInt16();
gzippedMap.Position = 0;
gzippedMap.Offset = reader.index;
@ -152,8 +151,9 @@ namespace ClassicalSharp.Network {
task.Interval = 1.0 / 20;
game.Gui.SetNewScreen( null );
game.Gui.activeScreen = prevScreen;
if( prevScreen != null && prevCursorVisible != game.CursorVisible )
if( prevScreen != null && prevCursorVisible != game.CursorVisible ) {
game.CursorVisible = prevCursorVisible;
}
prevScreen = null;
int mapWidth = reader.ReadInt16();

View File

@ -67,8 +67,9 @@ namespace ClassicalSharp.Network {
public override void Tick( ScheduledTask task ) {
if( Disconnected ) return;
if( (DateTime.UtcNow - lastPacket).TotalSeconds >= 30 )
if( (DateTime.UtcNow - lastPacket).TotalSeconds >= 30 ) {
CheckDisconnection( task.Interval );
}
if( Disconnected ) return;
LocalPlayer player = game.LocalPlayer;
@ -209,11 +210,13 @@ namespace ClassicalSharp.Network {
void BlockChanged( object sender, BlockChangedEventArgs e ) {
Vector3I p = e.Coords;
byte block = game.Inventory.HeldBlock;
if( e.Block == 0 )
if( e.Block == 0 ) {
SendSetBlock( p.X, p.Y, p.Z, false, block );
else
} else {
SendSetBlock( p.X, p.Y, p.Z, true, e.Block );
}
}
void OnNewMap( object sender, EventArgs e ) {
// wipe all existing entity states

View File

@ -57,7 +57,7 @@ namespace ClassicalSharp.Renderers {
game.WorldEvents.OnNewMap -= OnNewMap;
game.WorldEvents.OnNewMapLoaded -= OnNewMapLoaded;
game.WorldEvents.EnvVariableChanged -= EnvVariableChanged;
game.WorldEvents.BlockDefinitionChanged -= BlockDefinitionChanged;
game.Events.BlockDefinitionChanged -= BlockDefinitionChanged;
game.Events.ViewDistanceChanged -= ViewDistanceChanged;
game.Events.ProjectionChanged -= ProjectionChanged;
builder.Dispose();
@ -388,7 +388,7 @@ namespace ClassicalSharp.Renderers {
} else {
if( info.NormalParts != null )
IncrementUsed( info.NormalParts );
if (info.TranslucentParts != null )
if ( info.TranslucentParts != null )
IncrementUsed( info.TranslucentParts );
}
chunkUpdates++;