Solved some code errors (variable namings)

This commit is contained in:
Robin Kanters 2015-05-08 23:58:16 +02:00
parent c3f55df77a
commit 23ea9aa267

View File

@ -4,7 +4,6 @@ using System.Linq;
using TrueCraft.API.Server; using TrueCraft.API.Server;
using TrueCraft.API.Networking; using TrueCraft.API.Networking;
using TrueCraft.Core.Networking.Packets; using TrueCraft.Core.Networking.Packets;
using TrueCraft.API.Logging;
using TrueCraft.API; using TrueCraft.API;
using TrueCraft.Core.Entities; using TrueCraft.Core.Entities;
@ -12,58 +11,58 @@ namespace TrueCraft.Handlers
{ {
internal static class LoginHandlers internal static class LoginHandlers
{ {
public static void HandleHandshakePacket(IPacket _packet, IRemoteClient _client, IMultiplayerServer server) public static void HandleHandshakePacket(IPacket packet, IRemoteClient client, IMultiplayerServer server)
{ {
var packet = (HandshakePacket)_packet; var handshakePacket = (HandshakePacket) packet;
var client = (RemoteClient)_client; var remoteClient = (RemoteClient)client;
client.Username = packet.Username; remoteClient.Username = handshakePacket.Username;
client.QueuePacket(new HandshakeResponsePacket("-")); // TODO: Implement some form of authentication remoteClient.QueuePacket(new HandshakeResponsePacket("-")); // TODO: Implement some form of authentication
} }
public static void HandleLoginRequestPacket(IPacket _packet, IRemoteClient _client, IMultiplayerServer server) public static void HandleLoginRequestPacket(IPacket packet, IRemoteClient client, IMultiplayerServer server)
{ {
var packet = (LoginRequestPacket)_packet; var loginRequestPacket = (LoginRequestPacket)packet;
var client = (RemoteClient)_client; var remoteClient = (RemoteClient)client;
if (packet.ProtocolVersion < server.PacketReader.ProtocolVersion) if (loginRequestPacket.ProtocolVersion < server.PacketReader.ProtocolVersion)
client.QueuePacket(new DisconnectPacket("Client outdated! Use beta 1.7.3.")); remoteClient.QueuePacket(new DisconnectPacket("Client outdated! Use beta 1.7.3."));
else if (packet.ProtocolVersion > server.PacketReader.ProtocolVersion) else if (loginRequestPacket.ProtocolVersion > server.PacketReader.ProtocolVersion)
client.QueuePacket(new DisconnectPacket("Server outdated! Use beta 1.7.3.")); remoteClient.QueuePacket(new DisconnectPacket("Server outdated! Use beta 1.7.3."));
else if (server.Worlds.Count == 0) else if (server.Worlds.Count == 0)
client.QueuePacket(new DisconnectPacket("Server has no worlds configured.")); remoteClient.QueuePacket(new DisconnectPacket("Server has no worlds configured."));
else if (!PlayerIsWhitelisted(client, server) && PlayerIsBlacklisted(client, server)) else if (!PlayerIsWhitelisted(remoteClient, server) && PlayerIsBlacklisted(remoteClient, server))
client.QueuePacket(new DisconnectPacket("You're banned from this server")); remoteClient.QueuePacket(new DisconnectPacket("You're banned from this server"));
else else
{ {
client.LoggedIn = true; remoteClient.LoggedIn = true;
client.Entity = new PlayerEntity(client.Username); remoteClient.Entity = new PlayerEntity(remoteClient.Username);
client.World = server.Worlds[0]; remoteClient.World = server.Worlds[0];
client.ChunkRadius = 2; remoteClient.ChunkRadius = 2;
if (!client.Load()) if (!remoteClient.Load())
client.Entity.Position = client.World.SpawnPoint; remoteClient.Entity.Position = remoteClient.World.SpawnPoint;
// Send setup packets // Send setup packets
client.QueuePacket(new LoginResponsePacket(0, 0, Dimension.Overworld)); remoteClient.QueuePacket(new LoginResponsePacket(0, 0, Dimension.Overworld));
client.UpdateChunks(); remoteClient.UpdateChunks();
client.QueuePacket(new WindowItemsPacket(0, client.Inventory.GetSlots())); remoteClient.QueuePacket(new WindowItemsPacket(0, remoteClient.Inventory.GetSlots()));
client.QueuePacket(new SpawnPositionPacket((int)client.Entity.Position.X, remoteClient.QueuePacket(new SpawnPositionPacket((int)remoteClient.Entity.Position.X,
(int)client.Entity.Position.Y, (int)client.Entity.Position.Z)); (int)remoteClient.Entity.Position.Y, (int)remoteClient.Entity.Position.Z));
client.QueuePacket(new SetPlayerPositionPacket(client.Entity.Position.X, remoteClient.QueuePacket(new SetPlayerPositionPacket(remoteClient.Entity.Position.X,
client.Entity.Position.Y + 1, remoteClient.Entity.Position.Y + 1,
client.Entity.Position.Y + client.Entity.Size.Height + 1, remoteClient.Entity.Position.Y + remoteClient.Entity.Size.Height + 1,
client.Entity.Position.Z, client.Entity.Yaw, client.Entity.Pitch, true)); remoteClient.Entity.Position.Z, remoteClient.Entity.Yaw, remoteClient.Entity.Pitch, true));
client.QueuePacket(new TimeUpdatePacket(client.World.Time)); remoteClient.QueuePacket(new TimeUpdatePacket(remoteClient.World.Time));
// Start housekeeping for this client // Start housekeeping for this client
var entityManager = server.GetEntityManagerForWorld(client.World); var entityManager = server.GetEntityManagerForWorld(remoteClient.World);
entityManager.SpawnEntity(client.Entity); entityManager.SpawnEntity(remoteClient.Entity);
entityManager.SendEntitiesToClient(client); entityManager.SendEntitiesToClient(remoteClient);
server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(10), client.SendKeepAlive); server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(10), remoteClient.SendKeepAlive);
server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(1), client.ExpandChunkRadius); server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(1), remoteClient.ExpandChunkRadius);
if (!string.IsNullOrEmpty(Program.Configuration.MOTD)) if (!string.IsNullOrEmpty(Program.Configuration.MOTD))
client.SendMessage(Program.Configuration.MOTD); remoteClient.SendMessage(Program.Configuration.MOTD);
server.SendMessage(ChatColor.Yellow + "{0} joined the server.", client.Username); server.SendMessage(ChatColor.Yellow + "{0} joined the server.", remoteClient.Username);
} }
} }