public static double gamedistance(DarkEmu_GameServer.character._pos p1, DarkEmu_GameServer.character._pos p2) { // Nukei: for test with range checking on objects, maybe faster than only calculating distance if ((p1.xSec >= p2.xSec - 1) && (p1.xSec <= p2.xSec + 1) && (p1.ySec >= p2.ySec - 1) && (p1.ySec <= p2.ySec + 1)) { return gamedistance(p1.x, p1.y, p2.x, p2.y); } else { return 99999999999999; } }
///////////////////////////////////////////////////////////////////////////////// // Login user ///////////////////////////////////////////////////////////////////////////////// public static int LoginUser(string aID, ref string aPass, ref DarkEmu_GameServer.player aPlayer, bool localConnect) { //Console.WriteLine("Login User: {0} - {1}",aID,aPass); MsSQL ms = new MsSQL("SELECT * FROM users WHERE password='******'"); using (System.Data.SqlClient.SqlDataReader reader = ms.Read()) { if (Systems.clients.Count>=Systems.maxSlots) { ms.Close(); return 2; // crowded } while (reader.Read()) { if (reader.GetString(1).ToLower() == aID.ToLower()) // id { if (reader.GetByte(3) == 1) // online { ms.Close(); return 3; // already online } if (reader.GetInt32(5) == 1) // banned { aPass = reader.GetString(4); ms.Close(); return 4; // banned } if (aPlayer == null && localConnect) MsSQL.UpdateData("UPDATE users SET online=1 WHERE userid='" + reader.GetInt32(0) + "'"); aPlayer = new player(); aPlayer.AccountName = aID; aPlayer.Password = aPass; // Nukei: ?? whats the reason for saving password in memory ? aPlayer.ID = reader.GetInt32(0); aPlayer.pGold = reader.GetInt64(7); aPlayer.Silk = reader.GetInt32(6); aPlayer.SilkPrem = reader.GetInt32(9); aPlayer.wSlots = reader.GetByte(11); ms.Close(); //Console.WriteLine("Login..!!"); return 0; } } } ms.Close(); return 1; // not found }
//////////////////////////////////////////////////////////////////////////////////////////////////////////// // Movement Packet //////////////////////////////////////////////////////////////////////////////////////////////////////////// public static byte[] Movement(DarkEmu_GameServer.Global.vektor p) { PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_MOVEMENT); //Select opcode Writer.DWord(p.ID); //Player ID Writer.Bool(true); //Bool 1 Writer.Byte(p.xSec); //Player X Sector Writer.Byte(p.ySec); //Player Y Sector if (!File.FileLoad.CheckCave(p.xSec, p.ySec)) { Writer.Word(p.x); //Player X Location Writer.Word(p.z); //Player Z Location Writer.Word(p.y); //Player Y Location } else { if (p.x < 0) { Writer.Word(p.x); Writer.Word(0xFFFF); } else { Writer.DWord(p.x); } Writer.DWord(p.z); if (p.y < 0) { Writer.Word(p.y); Writer.Word(0xFFFF); } else { Writer.DWord(p.y); } } Writer.Bool(false); return Writer.GetBytes(); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////// // Movement Pickup //////////////////////////////////////////////////////////////////////////////////////////////////////////// public static byte[] MovementOnPickup(DarkEmu_GameServer.Global.vektor p) { PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_PICKUPITEM_MOVE); Writer.DWord(p.ID); Writer.Byte(p.xSec); Writer.Byte(p.ySec); Writer.Float(p.x); Writer.Float(p.z); Writer.Float(p.y); Writer.Word(0); return Writer.GetBytes(); }