//Sends a packet to the client with the matching connection ID public static void SendPacketTo(int ClientID, byte[] PacketData) { ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteBytes(PacketData); Clients[ClientID].ClientStream.BeginWrite(PacketWriter.ToArray(), 0, PacketWriter.ToArray().Length, null, null); PacketWriter.Dispose(); }
//tells a client where all the active entities are when they are first entering the server public static void SendActiveEntities(int ClientID) { //Initialise the header data of the network packet ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.SpawnActiveEntityList); //Find out how many active entities there are and write the count value in the packet data int EntityCount = EntityManager.ActiveEntities.Count; PacketWriter.WriteInteger(EntityCount); //Loop through each of the entities that are active in the scene right now List <ServerEntity> EntityList = EntityManager.GetEntityList(); foreach (ServerEntity entity in EntityList) { //We need to save each entities ID, Type, and World Position PacketWriter.WriteString(entity.ID); PacketWriter.WriteString(entity.Type); PacketWriter.WriteFloat(entity.entity.Position.X); PacketWriter.WriteFloat(entity.entity.Position.Y); PacketWriter.WriteFloat(entity.entity.Position.Z); } //Once the packet has all the information, close it and send it off to the client ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//tells each in the list of clients about every entity in that list public static void SendListEntityUpdates(List <Client> ClientList, List <BaseEntity> EntityList) { //Console.WriteLine("send entity updates"); ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.SendEntityUpdates); PacketWriter.WriteInteger(EntityList.Count); foreach (var BaseEntity in EntityList) { //ID PacketWriter.WriteString(BaseEntity.ID); //Position PacketWriter.WriteFloat(BaseEntity.Position.X); PacketWriter.WriteFloat(BaseEntity.Position.Y); PacketWriter.WriteFloat(BaseEntity.Position.Z); //Rotation PacketWriter.WriteFloat(BaseEntity.Rotation.X); PacketWriter.WriteFloat(BaseEntity.Rotation.Y); PacketWriter.WriteFloat(BaseEntity.Rotation.Z); PacketWriter.WriteFloat(BaseEntity.Rotation.W); } foreach (Client Client in ClientList) { ClientManager.SendPacketTo(Client.ClientID, PacketWriter.ToArray()); } PacketWriter.Dispose(); }
//tells a client to enter into the game world public static void SendPlayerEnterWorld(int ClientID) { Client Client = ClientManager.Clients[ClientID]; ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.PlayerEnterWorld); //write the packet type //we also want to pass information about all of the other clients already playing the game right now List <Client> OtherPlayers = ClientManager.GetActiveClientsExceptFor(ClientID); PacketWriter.WriteInteger(OtherPlayers.Count); //how many other players are in the game foreach (Client Other in OtherPlayers) { //Provide the information for each other player who is in the game PacketWriter.WriteString(Other.CurrentCharacterName); //characters name //characters position PacketWriter.WriteFloat(Other.CharacterPosition.X); PacketWriter.WriteFloat(Other.CharacterPosition.Y); PacketWriter.WriteFloat(Other.CharacterPosition.Z); } //send the packet to the client ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//tells each in the list of clients about every entity in that list public static void SendListEntityUpdates(List <Client> ClientList, List <ServerEntity> EntityList) { //Define a network packet which lists the updated targets for each entity in the given list ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.SendEntityUpdates); //The client will need to know how much entity updates are in the network packet PacketWriter.WriteInteger(EntityList.Count); //Now write in the required data for every entity in the list foreach (var Entity in EntityList) { //Entity ID PacketWriter.WriteString(Entity.ID); //New Entity Position PacketWriter.WriteFloat(Entity.entity.Position.X); PacketWriter.WriteFloat(Entity.entity.Position.Y); PacketWriter.WriteFloat(Entity.entity.Position.Z); //Their rotation values too PacketWriter.WriteFloat(Entity.entity.Orientation.X); PacketWriter.WriteFloat(Entity.entity.Orientation.Y); PacketWriter.WriteFloat(Entity.entity.Orientation.Z); PacketWriter.WriteFloat(Entity.entity.Orientation.W); } //The packet is ready, now send it to everyone in the list foreach (Client Client in ClientList) { ClientManager.SendPacketTo(Client.ClientID, PacketWriter.ToArray()); } //Close up the packet and finish off PacketWriter.Dispose(); }
//tells a client the info for each character they have created public static void SendCharacterData(int ClientID, string AccountName) { ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.SendCharacterData); //First we need to look up in the database how many characters this user has created so far int CharacterCount = Globals.database.GetCharacterCount(ClientID, AccountName); PacketWriter.WriteInteger(CharacterCount); //Now loop through and add all the information for each character that has already been created for (int i = 0; i < CharacterCount; i++) { //Get the name of each of the players characters one at a time string CharacterName = Globals.database.GetCharacterName(AccountName, i + 1); //Get all the data for this character from the database CharacterData Data = Globals.database.GetCharacterData(CharacterName); //Save all of this information into the packet PacketWriter.WriteString(Data.Account); PacketWriter.WriteFloat(Data.Position.X); PacketWriter.WriteFloat(Data.Position.Y); PacketWriter.WriteFloat(Data.Position.Z); PacketWriter.WriteString(Data.Name); PacketWriter.WriteInteger(Data.Experience); PacketWriter.WriteInteger(Data.ExperienceToLevel); PacketWriter.WriteInteger(Data.Level); PacketWriter.WriteInteger(Data.IsMale ? 1 : 0); } //Send the packet to the client ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//tells a client to remove someone elses character from their world public static void SendRemoveOtherPlayer(int ClientID, string CharacterName) { ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.RemoveOtherPlayer); //packet type PacketWriter.WriteString(CharacterName); ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//displays a message in the clients player chat window public static void SendPlayerMessage(int ClientID, string Sender, string Message) { ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.PlayerMessage); PacketWriter.WriteString(Sender); PacketWriter.WriteString(Message); ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//tells a client if they logged into the account public static void SendLoginReply(int ClientID, bool Success, string Message) { ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.LoginReply); PacketWriter.WriteInteger(Success ? 1 : 0); PacketWriter.WriteString(Message); ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//tells a client if their character was created public static void SendCreateCharacterReply(int ClientID, bool CreationSuccess, string ReplyMessage) { ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.CreateCharacterReply); PacketWriter.WriteInteger(CreationSuccess ? 1 : 0); PacketWriter.WriteString(ReplyMessage); ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//displays a message in the clients console log window public static void SendConsoleMessage(int ClientID, string Message) { //Create the packet to send through the network ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.ConsoleMessage); PacketWriter.WriteString(Message); //Send the packet to the target client ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//tells a client if their account was registered public static void SendRegisterReply(int ClientID, bool Success, string Message) { Console.WriteLine("send register reply"); ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.RegisterReply); PacketWriter.WriteInteger(Success ? 1 : 0); PacketWriter.WriteString(Message); ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//tells a client to spawn someone elses character into their game world public static void SendSpawnOther(int ClientID, string CharacterName, Vector3 Position) { ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.SpawnOtherPlayer); //packet type PacketWriter.WriteString(CharacterName); PacketWriter.WriteFloat(Position.X); PacketWriter.WriteFloat(Position.Y); PacketWriter.WriteFloat(Position.Z); ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//Sends the packet to every single client that is connected to the server public static void SendPacketToAll(byte[] PacketData) { ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteBytes(PacketData); foreach (var Client in Clients) { int ID = Client.Key; Client client = Client.Value; SendPacketTo(ID, PacketWriter.ToArray()); } PacketWriter.Dispose(); }
//Sends a packet to every single client that is connected for the server except for one of them whom nothing will be sent to public static void SendPacketToAllBut(int ClientID, byte[] PacketData) { ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteBytes(PacketData); foreach (var Client in Clients) { int ID = Client.Key; Client ClientData = Client.Value; if (ClientID == ID) { continue; } SendPacketTo(ID, PacketWriter.ToArray()); } PacketWriter.Dispose(); }
public void WorldStream() { Log.log("Starting world update thread..", Log.LogType.CACHE); ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); World.instance.BuildBuffer(ref buffer); while (Connected) { for (int i = 0; i < Network.instance.Clients.Length; i++) { World.instance.BuildBuffer(ref buffer); if (Network.instance.Clients[i].InGame()) { SendData.SendUDP_Packet(Network.instance.Clients[i], buffer.ToArray()); } } Thread.Sleep(World.TickRate); } WorldThread.Join(); }
//tells a client where all the active entities are when they are first entering the server public static void SendActiveEntities(int ClientID) { Console.WriteLine("send active entities"); ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.SpawnActiveEntityList); int EntityCount = EntityManager.ActiveEntities.Count; PacketWriter.WriteInteger(EntityCount); List <BaseEntity> EntityList = EntityManager.ActiveEntities; foreach (BaseEntity entity in EntityList) { PacketWriter.WriteString(entity.ID); PacketWriter.WriteFloat(entity.Position.X); PacketWriter.WriteFloat(entity.Position.Y); PacketWriter.WriteFloat(entity.Position.Z); } ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); PacketWriter.Dispose(); }
//tells a client to update someone elses position info public static void SendPlayerUpdatePosition(int ClientID, string CharacterName, Vector3 NewPosition, Quaternion NewRotation) { //Create the packet to send through the network ByteBuffer.ByteBuffer PacketWriter = new ByteBuffer.ByteBuffer(); PacketWriter.WriteInteger((int)ServerPacketType.PlayerUpdatePosition); //write the packet type PacketWriter.WriteString(CharacterName); //write the account name //write the position data PacketWriter.WriteFloat(NewPosition.X); PacketWriter.WriteFloat(NewPosition.Y); PacketWriter.WriteFloat(NewPosition.Z); //wrote the rotation data PacketWriter.WriteFloat(NewRotation.X); PacketWriter.WriteFloat(NewRotation.Y); PacketWriter.WriteFloat(NewRotation.Z); PacketWriter.WriteFloat(NewRotation.W); //send the packet to the client ClientManager.SendPacketTo(ClientID, PacketWriter.ToArray()); //close the packet writer PacketWriter.Dispose(); }
public static void Respawned(int index, int Current_HP, float x, float y, float z, float r) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)ClientSendPacketNumbers.Respawned, ref buffer); buffer.WriteString(DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss")); buffer.WriteInteger(Current_HP); buffer.WriteFloat(x); buffer.WriteFloat(y); buffer.WriteFloat(z); buffer.WriteFloat(r); Log.log("Sending Respawned packet to client..", Log.LogType.SENT); sendData(ConnectionType.CLIENT, ClientSendPacketNumbers.Respawned.ToString(), index, buffer.ToArray()); } catch (Exception e) { Log.log("Building Respawned packet failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void Heal(int index, int Current_HP, int Heal_Amount) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)ClientSendPacketNumbers.Heal, ref buffer); buffer.WriteString(DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss")); buffer.WriteInteger(Current_HP); buffer.WriteInteger(Heal_Amount); Log.log("Sending Heal packet to client..", Log.LogType.SENT); sendData(ConnectionType.CLIENT, ClientSendPacketNumbers.Heal.ToString(), index, buffer.ToArray()); } catch (Exception e) { Log.log("Building Heal packet failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void StompResponse(int index, List <DamageResponse> value) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)ClientSendPacketNumbers.StompResponse, ref buffer); buffer.WriteString(DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss")); buffer.WriteInteger(value.Count); for (int i = 0; i < value.Count; i++) { buffer.WriteInteger(value[i].NPC_Entity_ID); buffer.WriteInteger(value[i].New_HP); buffer.WriteInteger(value[i].Damage); buffer.WriteByte(value[i].Crit ? (byte)1 : (byte)0); } Log.log("Sending Stomp Response packet to client..", Log.LogType.SENT); sendData(ConnectionType.CLIENT, ClientSendPacketNumbers.StompResponse.ToString(), index, buffer.ToArray()); } catch (Exception e) { Log.log("Building Stomp Response packet failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void CharacterList(int index, bool success) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)ClientSendPacketNumbers.CharacterList, ref buffer); buffer.WriteByte((success) ? (byte)1 : (byte)0); buffer.WriteInteger(Network.instance.Clients[index].Characters.Count); if (success) { foreach (Character c in Network.instance.Clients[index].Characters) { buffer.WriteString(c.Name); buffer.WriteInteger(c.Level); buffer.WriteInteger(c.Gender); } } sendData(ConnectionType.CLIENT, (int)ClientSendPacketNumbers.CharacterList, index, buffer.ToArray()); } catch (Exception e) { Log.log("Building Character List packet failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void CreateCharacterResponse(int index, int Character_ID, string Name, int Gender) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)ClientSendPacketNumbers.CreateCharacterResponse, ref buffer); buffer.WriteInteger(Character_ID); buffer.WriteString(Name); buffer.WriteInteger(Gender); sendData(ConnectionType.CLIENT, (int)ClientSendPacketNumbers.CreateCharacterResponse, index, buffer.ToArray()); if (Character_ID > 0) { buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)GameServerSendPacketNumbers.CreateCharacterResponse, ref buffer); buffer.WriteInteger(Character_ID); buffer.WriteString(Name); buffer.WriteInteger(Gender); sendData(ConnectionType.GAMESERVER, (int)GameServerSendPacketNumbers.CreateCharacterResponse, index, buffer.ToArray()); buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)SyncServerSendPacketNumbers.CreateCharacterResponse, ref buffer); buffer.WriteInteger(Character_ID); buffer.WriteString(Name); buffer.WriteInteger(Gender); buffer.WriteString(Network.instance.Clients[index].Username); sendData(ConnectionType.SYNCSERVER, (int)SyncServerSendPacketNumbers.CreateCharacterResponse, index, buffer.ToArray()); } } catch (Exception e) { Log.log("Building Create Character Response failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void RegistrationNotification(int account_id, string username, string password, string email) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)SyncServerSendPacketNumbers.RegistrationNotification, ref buffer); buffer.WriteInteger(account_id); buffer.WriteString(username); buffer.WriteString(password); buffer.WriteString(email); sendData(ConnectionType.SYNCSERVER, (int)SyncServerSendPacketNumbers.RegistrationNotification, -1, buffer.ToArray()); } catch (Exception e) { Log.log("Building Registration Notification packet failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void WhiteListConfirmation(string ip) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)GameServerSendPacketNumbers.WhiteList, ref buffer); buffer.WriteString(ip); sendData(ConnectionType.GAMESERVER, (int)GameServerSendPacketNumbers.WhiteList, -1, buffer.ToArray()); } catch (Exception e) { Log.log("Building White List Confirmation packet failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void LoginResponse(int index, byte response) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)ClientSendPacketNumbers.LoginResponse, ref buffer); buffer.WriteByte(response); sendData(ConnectionType.CLIENT, (int)ClientSendPacketNumbers.LoginResponse, index, buffer.ToArray()); } catch (Exception e) { Log.log("Building Login Response packet failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void Authenticate(Connection connection) { if (!connection.Authenticated) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)ServerSendPacketNumbers.AuthenticateGameServer, ref buffer); buffer.WriteString(Network.instance.AuthenticationCode); sendData(connection.Type, ServerSendPacketNumbers.AuthenticateGameServer.ToString(), buffer.ToArray()); } catch (Exception e) { Log.log("Building Authentication packet failed. > " + e.Message, Log.LogType.ERROR); return; } } else { Log.log("An attempt was made to send an authentication packet, the " + connection.Type.ToString() + " is already authenticated.", Log.LogType.ERROR); } }
public static void NewQuestLog(_Quest_Log ql) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); Log.log("Sending New Quest Log response.", Log.LogType.SENT); BuildBasePacket((int)GameServerSendPacketNumbers.NewQuestLog, ref buffer); buffer.WriteInteger(ql.Character_ID); buffer.WriteInteger(ql.Quest_ID); buffer.WriteInteger(ql.Log_ID); sendData(ConnectionType.GAMESERVER, GameServerSendPacketNumbers.NewQuestLog.ToString(), buffer.ToArray()); } catch (Exception e) { Log.log("Building New Quest Log packet failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void WorldRequest() { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); Log.log("Sending world request response.", Log.LogType.SENT); float TimeBetween = 0.5f; DateTime NextPacket = DateTime.Now; // tbl_Characters BuildBasePacket((int)GameServerSendPacketNumbers.WorldRequest, ref buffer); int LineNumber = Log.log("Sending tbl_Characters..", Log.LogType.SENT); buffer.WriteInteger((int)SyncServerTable.tbl_Characters); buffer.WriteInteger(Data.tbl_Characters.Count); foreach (KeyValuePair <int, _Characters> character in Data.tbl_Characters) { buffer.WriteInteger(character.Key); buffer.WriteString(character.Value.Character_Name); buffer.WriteInteger(character.Value.Character_Level); buffer.WriteInteger(character.Value.Gender); buffer.WriteFloat(character.Value.Pos_X); buffer.WriteFloat(character.Value.Pos_Y); buffer.WriteFloat(character.Value.Pos_Z); buffer.WriteFloat(character.Value.Rotation_Y); buffer.WriteInteger(character.Value.Health); buffer.WriteInteger(character.Value.Strength); buffer.WriteInteger(character.Value.Agility); buffer.WriteInteger(character.Value.Experience); buffer.WriteFloat(character.Value.Camera_Pos_X); buffer.WriteFloat(character.Value.Camera_Pos_Y); buffer.WriteFloat(character.Value.Camera_Pos_Z); buffer.WriteFloat(character.Value.Camera_Rotation_Y); Log.log(LineNumber, "Sending tbl_Characters.. Character ID " + character.Key.ToString() + "/" + Data.tbl_Characters.Count.ToString(), Log.LogType.SENT); } sendData(ConnectionType.GAMESERVER, GameServerSendPacketNumbers.WorldRequest.ToString(), buffer.ToArray()); NextPacket = DateTime.Now.AddSeconds(TimeBetween); while (DateTime.Now < NextPacket) { } // tbl_NPC buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)GameServerSendPacketNumbers.WorldRequest, ref buffer); LineNumber = Log.log("Sending tbl_NPC..", Log.LogType.SENT); buffer.WriteInteger((int)SyncServerTable.tbl_NPC); buffer.WriteInteger(Data.tbl_NPC.Count); foreach (KeyValuePair <int, _NPC> npc in Data.tbl_NPC) { buffer.WriteInteger(npc.Key); buffer.WriteInteger(npc.Value.Status); buffer.WriteString(npc.Value.Name); buffer.WriteInteger(npc.Value.Respawn_Time); buffer.WriteInteger(npc.Value.Level); buffer.WriteInteger(npc.Value.Gender); buffer.WriteInteger(npc.Value.HP); buffer.WriteInteger(npc.Value.Strength); buffer.WriteInteger(npc.Value.Agility); buffer.WriteInteger(npc.Value.Experience); Log.log(LineNumber, "Sending tbl_NPC.. NPC ID " + npc.Key.ToString() + "/" + Data.tbl_NPC.Count.ToString(), Log.LogType.SENT); } sendData(ConnectionType.GAMESERVER, GameServerSendPacketNumbers.WorldRequest.ToString(), buffer.ToArray()); NextPacket = DateTime.Now.AddSeconds(TimeBetween); while (DateTime.Now < NextPacket) { } // tbl_Quests buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)GameServerSendPacketNumbers.WorldRequest, ref buffer); LineNumber = Log.log("Sending tbl_Quests..", Log.LogType.SENT); buffer.WriteInteger((int)SyncServerTable.tbl_Quests); buffer.WriteInteger(Data.tbl_Quests.Count); foreach (KeyValuePair <int, _Quests> quest in Data.tbl_Quests) { buffer.WriteInteger(quest.Key); buffer.WriteString(quest.Value.Title); buffer.WriteString(quest.Value.Start_Text); buffer.WriteString(quest.Value.End_Text); buffer.WriteInteger(quest.Value.Reward_ID); buffer.WriteInteger(quest.Value.NPC_Start_ID); buffer.WriteInteger(quest.Value.NPC_End_ID); buffer.WriteInteger(quest.Value.Objective_Target); buffer.WriteInteger(quest.Value.Start_Requirement_Quest_ID); buffer.WriteInteger(quest.Value.Item_Objective_ID); buffer.WriteInteger(quest.Value.NPC_Objective_ID); buffer.WriteInteger(quest.Value.Experience); Log.log(LineNumber, "Sending tbl_Quests.. Quest ID " + quest.Key.ToString() + "/" + Data.tbl_Quests.Count.ToString(), Log.LogType.SENT); } sendData(ConnectionType.GAMESERVER, GameServerSendPacketNumbers.WorldRequest.ToString(), buffer.ToArray()); NextPacket = DateTime.Now.AddSeconds(TimeBetween); while (DateTime.Now < NextPacket) { } // tbl_Collectables buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)GameServerSendPacketNumbers.WorldRequest, ref buffer); LineNumber = Log.log("Sending tbl_Collectables..", Log.LogType.SENT); buffer.WriteInteger((int)SyncServerTable.tbl_Collectables); buffer.WriteInteger(Data.tbl_Collectables.Count); foreach (KeyValuePair <int, _Collectables> col in Data.tbl_Collectables) { buffer.WriteInteger(col.Key); buffer.WriteString(col.Value.Collectable_Name); buffer.WriteInteger(col.Value.Respawn_Time); Log.log(LineNumber, "Sending tbl_Collectables.. Collectable ID " + col.Key.ToString() + "/" + Data.tbl_Collectables.Count.ToString(), Log.LogType.SENT); } sendData(ConnectionType.GAMESERVER, GameServerSendPacketNumbers.WorldRequest.ToString(), buffer.ToArray()); NextPacket = DateTime.Now.AddSeconds(TimeBetween); while (DateTime.Now < NextPacket) { } // tbl_Spawn_Positions buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)GameServerSendPacketNumbers.WorldRequest, ref buffer); LineNumber = Log.log("Sending tbl_Spawn_Positions..", Log.LogType.SENT); buffer.WriteInteger((int)SyncServerTable.tbl_Spawn_Positions); buffer.WriteInteger(Data.tbl_Spawn_Positions.Count); foreach (KeyValuePair <int, _Spawn_Positions> sp in Data.tbl_Spawn_Positions) { buffer.WriteInteger(sp.Key); buffer.WriteFloat(sp.Value.Pos_X); buffer.WriteFloat(sp.Value.Pos_Y); buffer.WriteFloat(sp.Value.Pos_Z); buffer.WriteFloat(sp.Value.Rotation_Y); buffer.WriteInteger(sp.Value.NPC_ID); buffer.WriteInteger(sp.Value.Collectable_ID); Log.log(LineNumber, "Sending tbl_Spawn_Positions.. Spawn ID " + sp.Key.ToString() + "/" + Data.tbl_Spawn_Positions.Count.ToString(), Log.LogType.SENT); } sendData(ConnectionType.GAMESERVER, GameServerSendPacketNumbers.WorldRequest.ToString(), buffer.ToArray()); NextPacket = DateTime.Now.AddSeconds(TimeBetween); while (DateTime.Now < NextPacket) { } // tbl_Quest_Log buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)GameServerSendPacketNumbers.WorldRequest, ref buffer); LineNumber = Log.log("Sending tbl_Quest_Log..", Log.LogType.SENT); buffer.WriteInteger((int)SyncServerTable.tbl_Quest_Log); buffer.WriteInteger(Data.tbl_Quest_Log.Count); foreach (KeyValuePair <int, _Quest_Log> ql in Data.tbl_Quest_Log) { buffer.WriteInteger(ql.Key); buffer.WriteInteger(ql.Value.Character_ID); buffer.WriteInteger(ql.Value.Quest_ID); buffer.WriteInteger(ql.Value.Quest_Status); buffer.WriteInteger(ql.Value.Progress); Log.log(LineNumber, "Sending tbl_Quest_Log.. Quest Log ID " + ql.Key.ToString() + "/" + Data.tbl_Quest_Log.Count.ToString(), Log.LogType.SENT); } sendData(ConnectionType.GAMESERVER, GameServerSendPacketNumbers.WorldRequest.ToString(), buffer.ToArray()); NextPacket = DateTime.Now.AddSeconds(TimeBetween); while (DateTime.Now < NextPacket) { } // tbl_Experience buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)GameServerSendPacketNumbers.WorldRequest, ref buffer); LineNumber = Log.log("Sending tbl_Experience..", Log.LogType.SENT); buffer.WriteInteger((int)SyncServerTable.tbl_Experience); buffer.WriteInteger(Data.tbl_Experience.Count); foreach (KeyValuePair <int, _Experience> ex in Data.tbl_Experience) { buffer.WriteInteger(ex.Key); buffer.WriteInteger(ex.Value.Level); buffer.WriteInteger(ex.Value.Experience); buffer.WriteInteger(ex.Value.Strength); buffer.WriteInteger(ex.Value.Agility); buffer.WriteInteger(ex.Value.HP); Log.log(LineNumber, "Sending tbl_Experience.. Experience ID " + ex.Key.ToString() + "/" + Data.tbl_Experience.Count.ToString(), Log.LogType.SENT); } sendData(ConnectionType.GAMESERVER, GameServerSendPacketNumbers.WorldRequest.ToString(), buffer.ToArray()); } catch (Exception e) { Log.log("Building World update packet failed. > " + e.Message, Log.LogType.ERROR); return; } }
public static void ConfirmWhiteList(int index) { try { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); BuildBasePacket((int)ClientSendPacketNumbers.ConfirmWhiteList, ref buffer); sendData(ConnectionType.CLIENT, (int)ClientSendPacketNumbers.ConfirmWhiteList, index, buffer.ToArray()); } catch (Exception e) { Log.log("Building White List Confirmation packet failed. > " + e.Message, Log.LogType.ERROR); return; } }