public void Initialize(Socket sender) { PlayerCharacter playerCharacter = User.Instance.Character; Debug debug = new Debug(); ServerName = GetServerName(playerCharacter.WorldId); ChatProcessor.SendMessage(sender, MessageType.GeneralInfo, "Welcome to " + ServerName + "!"); ChatProcessor.SendMessage(sender, MessageType.GeneralInfo, "Welcome to Eorzea!"); ChatProcessor.SendMessage(sender, MessageType.GeneralInfo, @"To get a list of available commands, type \help in the chat window and hit enter."); uint currentZone = playerCharacter.Position.ZoneId; Zone zone = Zones.Find(x => x.Id == currentZone); playerCharacter.SendGroupPackets(sender); if (true) //if playercharacter didnt reach after-opening map { OpeningDirector opening0 = new OpeningDirector(0x66080000); OpeningDirector opening1 = new OpeningDirector(0x66080001); opening0.Spawn(sender); opening0.StartClientOrderEvent(sender); } //zone environment init SetIsZoning(sender); SetDalamudPhase(sender); SetMusic(sender, zone.GetCurrentBGM()); SetWeather(sender, Weather.Clear); SetMap(sender, zone); //spawn actors playerCharacter.Spawn(sender, spawnType: 0x01, isZoning: 0); //spawn player character zone.Spawn(sender); //spawn zone debug.Spawn(sender); Spawn(sender, 0x01); zone.SpawnActors(sender); //TestPackets.Populace(playerCharacter.Id, null, sender); }
/// <summary> /// Processes the command for the gamepacket inside the current subpacket. /// </summary> ///<param name="subpacket">The received subpacket.</param> private void ProcessGamePacket(SubPacket subpacket) { //_world.Sender = _connection.socket; ushort opcode = (ushort)(subpacket.Data[0x03] << 8 | subpacket.Data[0x02]); switch (opcode) { case (ushort)ClientOpcode.Ping: Pong(subpacket); break; case (ushort)ClientOpcode.Unknown0x02: User.Instance.Character.Unknown0x02(_connection.socket); break; case (ushort)ClientOpcode.ChatMessage: ChatProcessor.Incoming(_connection.socket, subpacket.Data); break; case (ushort)ClientOpcode.Initialize: World.Instance.Initialize(_connection.socket); break; case (ushort)ClientOpcode.FriendListRequest: User.Instance.Character.GetFriendlist(_connection.socket); break; case (ushort)ClientOpcode.BlacklistRequest: User.Instance.Character.GetBlackList(_connection.socket); break; case (ushort)ClientOpcode.PlayerPosition: User.Instance.Character.UpdatePosition(subpacket.Data); break; case (ushort)ClientOpcode.Unknown0x07: //Log.Instance.Warning("Received command 0x07"); break; case (ushort)ClientOpcode.InitGroupWork: User.Instance.Character.SetGroupInitWork(_connection.socket, subpacket.Data); break; case (ushort)ClientOpcode.EventRequest: //EventManager.Instance. ProcessEventRequest(subpacket.Data); break; case (ushort)ClientOpcode.DataRequest: string request = Encoding.ASCII.GetString(subpacket.Data).Substring(0x14, 0x20).Trim(new[] { '\0' }); switch (request) { case "charaWork/exp": _connection.Send(User.Instance.Character.CharaWorkExp(_connection.socket)); break; } break; case (ushort)ClientOpcode.SelectTarget: User.Instance.Character.SelectTarget(_connection.socket, subpacket.Data); break; case (ushort)ClientOpcode.LockOnTarget: Log.Instance.Warning("Target locked"); break; case (ushort)ClientOpcode.EventResult: EventManager.Instance.CurrentEvent.EndClientOrderEvent(_connection.socket, ""); //EventManager.Instance.EventResult(_connection.socket, subpacket.Data); //User.Instance.Character.EndClientOrderEvent(_connection.socket, "commandContent"); //Log.Instance.Error("[" + World.Name + "] Event Result packet: 0x" + opcode.ToString("X")); File.WriteAllBytes("client_eventresult_" + DateTime.Now.Ticks.ToString() + ".txt", subpacket.Data); //World.Instance.TeleportMenuLevel2(_connection.socket, subpacket.Data); break; case (ushort)ClientOpcode.GMTicketActiveRequest: World.Instance.GMActiveRequest(_connection.socket); break; case (ushort)ClientOpcode.CutSceneFinished: Log.Instance.Success("Cutscene finished."); break; default: Log.Instance.Error("[" + World.Instance.ServerName + "] Unknown command: 0x" + opcode.ToString("X")); break; } }