mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
Include username in window title and add rand() to direct connect screen (Thanks Fudgie), also avoid rendering empty translucent batches twice. Improves FPS by 4-5 on 1024^3 maps.
This commit is contained in:
parent
e150da7e85
commit
cac62b14db
@ -463,7 +463,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public Game( string username, string mppass, string skinServer,
|
public Game( string username, string mppass, string skinServer,
|
||||||
bool nullContext, int width, int height )
|
bool nullContext, int width, int height )
|
||||||
: base( width, height, GraphicsMode.Default, Program.AppName, nullContext, 0, DisplayDevice.Default ) {
|
: base( width, height, GraphicsMode.Default, Program.AppName + " (" + username + ")", nullContext, 0, DisplayDevice.Default ) {
|
||||||
Username = username;
|
Username = username;
|
||||||
Mppass = mppass;
|
Mppass = mppass;
|
||||||
this.skinServer = skinServer;
|
this.skinServer = skinServer;
|
||||||
|
@ -36,7 +36,7 @@ namespace ClassicalSharp {
|
|||||||
if( args.Length == 0 || args.Length == 1 ) {
|
if( args.Length == 0 || args.Length == 1 ) {
|
||||||
const string skinServer = "http://s3.amazonaws.com/MinecraftSkins/";
|
const string skinServer = "http://s3.amazonaws.com/MinecraftSkins/";
|
||||||
|
|
||||||
using( Game game = new Game( "LocalPlayer", null, skinServer, nullContext, width, height ) )
|
using( Game game = new Game( "Singleplayer", null, skinServer, nullContext, width, height ) )
|
||||||
game.Run();
|
game.Run();
|
||||||
} else if( args.Length < 4 ) {
|
} else if( args.Length < 4 ) {
|
||||||
Utils.LogDebug( "ClassicalSharp.exe is only the raw client. You must either use the launcher or"
|
Utils.LogDebug( "ClassicalSharp.exe is only the raw client. You must either use the launcher or"
|
||||||
|
@ -49,6 +49,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
ChunkPartInfo part = info.TranslucentParts[batch];
|
ChunkPartInfo part = info.TranslucentParts[batch];
|
||||||
if( part.IndicesCount == 0 ) continue;
|
if( part.IndicesCount == 0 ) continue;
|
||||||
|
usedTranslucent[batch] = true;
|
||||||
DrawTranslucentPart( info, ref part );
|
DrawTranslucentPart( info, ref part );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,13 @@ namespace ClassicalSharp {
|
|||||||
ChunkInfo[] chunks, unsortedChunks;
|
ChunkInfo[] chunks, unsortedChunks;
|
||||||
Vector3I chunkPos = new Vector3I( int.MaxValue, int.MaxValue, int.MaxValue );
|
Vector3I chunkPos = new Vector3I( int.MaxValue, int.MaxValue, int.MaxValue );
|
||||||
int elementsPerBitmap = 0;
|
int elementsPerBitmap = 0;
|
||||||
|
bool[] usedTranslucent;
|
||||||
|
|
||||||
public MapRenderer( Game game ) {
|
public MapRenderer( Game game ) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
_1Dcount = game.TerrainAtlas1D.TexIds.Length;
|
_1Dcount = game.TerrainAtlas1D.TexIds.Length;
|
||||||
_1DUsed = game.TerrainAtlas1D.CalcMaxUsedRow( game.TerrainAtlas, game.BlockInfo );
|
_1DUsed = game.TerrainAtlas1D.CalcMaxUsedRow( game.TerrainAtlas, game.BlockInfo );
|
||||||
|
usedTranslucent = new bool[_1DUsed];
|
||||||
|
|
||||||
builder = new ChunkMeshBuilder( game );
|
builder = new ChunkMeshBuilder( game );
|
||||||
api = game.Graphics;
|
api = game.Graphics;
|
||||||
@ -91,10 +93,12 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
elementsPerBitmap = game.TerrainAtlas1D.elementsPerBitmap;
|
elementsPerBitmap = game.TerrainAtlas1D.elementsPerBitmap;
|
||||||
_1DUsed = game.TerrainAtlas1D.CalcMaxUsedRow( game.TerrainAtlas, game.BlockInfo );
|
_1DUsed = game.TerrainAtlas1D.CalcMaxUsedRow( game.TerrainAtlas, game.BlockInfo );
|
||||||
|
usedTranslucent = new bool[_1DUsed];
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockDefinitionChanged( object sender, EventArgs e ) {
|
void BlockDefinitionChanged( object sender, EventArgs e ) {
|
||||||
_1DUsed = game.TerrainAtlas1D.CalcMaxUsedRow( game.TerrainAtlas, game.BlockInfo );
|
_1DUsed = game.TerrainAtlas1D.CalcMaxUsedRow( game.TerrainAtlas, game.BlockInfo );
|
||||||
|
usedTranslucent = new bool[_1DUsed];
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnNewMap( object sender, EventArgs e ) {
|
void OnNewMap( object sender, EventArgs e ) {
|
||||||
@ -316,6 +320,7 @@ namespace ClassicalSharp {
|
|||||||
api.AlphaBlending = false;
|
api.AlphaBlending = false;
|
||||||
api.ColourWrite = false;
|
api.ColourWrite = false;
|
||||||
for( int batch = 0; batch < _1DUsed; batch++ ) {
|
for( int batch = 0; batch < _1DUsed; batch++ ) {
|
||||||
|
usedTranslucent[batch] = false;
|
||||||
RenderTranslucentBatchDepthPass( batch );
|
RenderTranslucentBatchDepthPass( batch );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,6 +331,7 @@ namespace ClassicalSharp {
|
|||||||
api.DepthWrite = false; // we already calculated depth values in depth pass
|
api.DepthWrite = false; // we already calculated depth values in depth pass
|
||||||
|
|
||||||
for( int batch = 0; batch < _1DUsed; batch++ ) {
|
for( int batch = 0; batch < _1DUsed; batch++ ) {
|
||||||
|
if( !usedTranslucent[batch] ) continue;
|
||||||
api.BindTexture( texIds[batch] );
|
api.BindTexture( texIds[batch] );
|
||||||
RenderTranslucentBatch( batch );
|
RenderTranslucentBatch( batch );
|
||||||
}
|
}
|
||||||
|
@ -134,10 +134,10 @@ namespace Launcher2 {
|
|||||||
if( !Options.Load() )
|
if( !Options.Load() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Options.Set( "launcher-dc-username", data.Username );
|
Options.Set( "launcher-dc-username", data.RealUsername );
|
||||||
Options.Set( "launcher-dc-ip", data.Ip );
|
Options.Set( "launcher-dc-ip", data.Ip );
|
||||||
Options.Set( "launcher-dc-port", data.Port );
|
Options.Set( "launcher-dc-port", data.Port );
|
||||||
Options.Set( "launcher-dc-mppass", Secure.Encode( data.Mppass, data.Username ) );
|
Options.Set( "launcher-dc-mppass", Secure.Encode( data.Mppass, data.RealUsername ) );
|
||||||
Options.Set( "launcher-dc-ccskins", ccSkins );
|
Options.Set( "launcher-dc-ccskins", ccSkins );
|
||||||
Options.Save();
|
Options.Save();
|
||||||
}
|
}
|
||||||
@ -159,6 +159,8 @@ namespace Launcher2 {
|
|||||||
Client.Start( data, ccSkins, ref game.ShouldExit );
|
Client.Start( data, ccSkins, ref game.ShouldExit );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Random rnd = new Random();
|
||||||
|
static byte[] rndBytes = new byte[8];
|
||||||
ClientStartData GetStartData( string user, string mppass, string ip, string port ) {
|
ClientStartData GetStartData( string user, string mppass, string ip, string port ) {
|
||||||
SetStatus( "" );
|
SetStatus( "" );
|
||||||
|
|
||||||
@ -179,7 +181,13 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
if( String.IsNullOrEmpty( mppass ) )
|
if( String.IsNullOrEmpty( mppass ) )
|
||||||
mppass = "(none)";
|
mppass = "(none)";
|
||||||
return new ClientStartData( user, mppass, ip, port );
|
|
||||||
|
ClientStartData data = new ClientStartData( user, mppass, ip, port );
|
||||||
|
if( user.ToLowerInvariant() == "rand()" || user.ToLowerInvariant() == "random()") {
|
||||||
|
rnd.NextBytes( rndBytes );
|
||||||
|
data.Username = Convert.ToBase64String( rndBytes ).TrimEnd( '=' );
|
||||||
|
}
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,10 @@ namespace Launcher2 {
|
|||||||
shouldExit = Options.GetBool( OptionsKey.AutoCloseLauncher, false );
|
shouldExit = Options.GetBool( OptionsKey.AutoCloseLauncher, false );
|
||||||
if( data == null ) return;
|
if( data == null ) return;
|
||||||
|
|
||||||
Options.Set( "launcher-username", data.Username );
|
Options.Set( "launcher-username", data.RealUsername );
|
||||||
Options.Set( "launcher-ip", data.Ip );
|
Options.Set( "launcher-ip", data.Ip );
|
||||||
Options.Set( "launcher-port", data.Port );
|
Options.Set( "launcher-port", data.Port );
|
||||||
Options.Set( "launcher-mppass", Secure.Encode( data.Mppass, data.Username ) );
|
Options.Set( "launcher-mppass", Secure.Encode( data.Mppass, data.RealUsername ) );
|
||||||
Options.Set( "launcher-ccskins", classiCubeSkins );
|
Options.Set( "launcher-ccskins", classiCubeSkins );
|
||||||
Options.Save();
|
Options.Save();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
public string Username;
|
public string Username;
|
||||||
|
|
||||||
|
public string RealUsername;
|
||||||
|
|
||||||
public string Mppass;
|
public string Mppass;
|
||||||
|
|
||||||
public string Ip;
|
public string Ip;
|
||||||
@ -17,6 +19,7 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
public ClientStartData( string user, string mppass, string ip, string port ) {
|
public ClientStartData( string user, string mppass, string ip, string port ) {
|
||||||
Username = user;
|
Username = user;
|
||||||
|
RealUsername = user;
|
||||||
Mppass = mppass;
|
Mppass = mppass;
|
||||||
Ip = ip;
|
Ip = ip;
|
||||||
Port = port;
|
Port = port;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user