Ejemplo n.º 1
0
        // This is the case that determines where the player is going to be. It will send the
        // TransSceneType and GameLocation.
        // There are multiple locations to send such as Space, Room, Story etc.
        public void SendLoadNextScene(int index)
        {
            BgoProtocolWriter buffer = NewMessage();

            buffer.Write((ushort)Reply.LoadNextScene);

            Character charIndex = Server.GetClientByIndex(index).Character;

            buffer.Write((byte)charIndex.getTransSceneType());
            buffer.Write((byte)charIndex.GameLocation);

            switch (charIndex.GameLocation)
            {
            case GameLocation.Starter:
                buffer.Write((uint)3027);     //ColonialBonusGUID
                buffer.Write((uint)3127);     //CylonBonusGUID
                break;

            case GameLocation.Avatar:
                buffer.Write((ushort)0); // No idea since the game doesn't use this (it does, but for a loop that does nothing).
                buffer.Write(false);     // No idea since the game doesn't use this.
                break;

            case GameLocation.Room:

                break;

            case GameLocation.Space:
            case GameLocation.Story:
            case GameLocation.BattleSpace:
            case GameLocation.Tournament:
            case GameLocation.Tutorial:
            case GameLocation.Teaser:
                // I'm not sure where to send these. I feel like sending every time the user enters the
                // Space is wrong.

                PlayerProtocol.GetProtocol().SendPlayerId(index);
                PlayerProtocol.GetProtocol().SendName(index);
                PlayerProtocol.GetProtocol().SendAvatar(index);
                PlayerProtocol.GetProtocol().SendFaction(index);
                PlayerProtocol.GetProtocol().SendPlayerShips(index, 100, (uint)22131177);

                PlayerProtocol.GetProtocol().SetActivePlayerShip(index, 100);

                // I don't know which values to give so I'm just giving the numbers in order. E.g:
                // ColonialBonusGUID was 3027 and CylonBonusGUID was 3127. So here we have 1327 and 1427 :) lol
                buffer.Write((uint)1327);     // sector id
                buffer.Write((uint)1427);     // cardGuid2
                break;
            }

            SendMessageToUser(index, buffer);
        }
Ejemplo n.º 2
0
        private void InitLogin(int index, uint playerId, string playerName, string sessionCode)
        {
            Server.GetClientByIndex(index).Character = new Character(index);
            SendPlayer(index);

            if (Database.Database.CheckCharacterExistanceById(playerId.ToString()))
            {
                CatalogueProtocol.GetProtocol().SendCard(index, CardView.GUI, 130920111u);
                CatalogueProtocol.GetProtocol().SendCard(index, CardView.GUI, 264733124u);
                CatalogueProtocol.GetProtocol().SendCard(index, CardView.GUI, 215278030u);
                CatalogueProtocol.GetProtocol().SendCard(index, CardView.GUI, 207047790u);
                CatalogueProtocol.GetProtocol().SendCard(index, CardView.GUI, 130762195u);

                PlayerProtocol.GetProtocol().SendPlayerId(index);
                PlayerProtocol.GetProtocol().SendName(index);
                PlayerProtocol.GetProtocol().SendAvatar(index);
                PlayerProtocol.GetProtocol().SendFaction(index);
                if (Server.GetClientByIndex(index).Character.Faction == Faction.Colonial)
                {
                    PlayerProtocol.GetProtocol().SendPlayerShips(index, 11, 22131180u);
                    PlayerProtocol.GetProtocol().SendPlayerShips(index, 17, 22131178u);
                    PlayerProtocol.GetProtocol().SendPlayerShips(index, 14, 22131196u);
                }
                else if (Server.GetClientByIndex(index).Character.Faction == Faction.Cylon)
                {
                    PlayerProtocol.GetProtocol().SendCylonDuties(index); // I only have Cylon duties
                    PlayerProtocol.GetProtocol().SendPlayerShips(index, 11, 22131208u);
                    PlayerProtocol.GetProtocol().SendPlayerShips(index, 17, 22131210u);
                    PlayerProtocol.GetProtocol().SendPlayerShips(index, 14, 22131226u);
                }
                PlayerProtocol.GetProtocol().SetActivePlayerShip(index, 11);

                PlayerProtocol.GetProtocol().SendItems(index);

                Database.Entities.Users user = Database.Database.GetUserById(Server.GetClientByIndex(index).playerId.ToString());
                SettingProtocol.ReadSettingsFromDatabase(index, user.settings);
                if (user.controlKeys != null)
                {
                    SettingProtocol.ReadControlKeysFromDatabase(index, user.controlKeys);
                }
                SettingProtocol.GetProtocol().SendSettings(index);
                if (Server.GetClientByIndex(index).Character.controlKeys.Count > 0)
                {
                    SettingProtocol.GetProtocol().SendKeys(index);
                }
                CommunityProtocol.GetProtocol().SendChatSessionId(index);
            }
        }
Ejemplo n.º 3
0
        public override void ParseMessage(int index, BgoProtocolReader br)
        {
            ushort msgType = (ushort)br.ReadUInt16();

            switch ((Request)msgType)
            {
            // I'm not sure if the JumpIn request did send the WhoIs of the player, but it works I guess.
            // Also I don't know if it was sent to everyone or just to the client. Probably everyone on the sector,
            // but since we are doing this offline for now, let's keep it still only client.
            case Request.JumpIn:
                SendWhoIsPlayer(index);
                SetTimeOrigin(index);
                PlayerProtocol.GetProtocol().SendStats(index);     // These are the stats of your ship, not the base ones.

                SyncMove(index, SpaceEntityType.Player, (uint)index, new Vector3(0, 100f, 100f));
                break;

            case Request.CompleteJump:
                PlayerProtocol.GetProtocol().SendUnanchor(index);
                StoryProtocol.GetProtocol().EnableGear(index, true);
                break;

            case Request.SetSpeed:
                byte  mode  = br.ReadByte();
                float speed = br.ReadSingle();
                Server.GetClientByIndex(index).Character.shipMode  = mode;
                Server.GetClientByIndex(index).Character.shipSpeed = speed;
                SyncMove(index, SpaceEntityType.Player, (uint)index);
                break;

            case Request.WASD:
                Server.GetClientByIndex(index).Character.qweasd = br.ReadByte();
                SyncMove(index, SpaceEntityType.Player, (uint)index);
                break;

            default:
                Log.Add(LogSeverity.ERROR, string.Format("Unknown msgType \"{0}\" on {1}Protocol.", (Request)msgType, protocolID));
                break;
            }
        }
Ejemplo n.º 4
0
        public override void ParseMessage(int index, BgoProtocolReader br)
        {
            ushort msgType = br.ReadUInt16();

            switch ((Request)msgType)
            {
            case Request.JumpIn:
                Client c = Server.GetClientByIndex(index);
                Server.GetSectorById(c.Character.PlayerShip.sectorId).JoinSector(c);
                break;

            case Request.CompleteJump:
                PlayerProtocol.GetProtocol().SendUnanchor(index, Server.GetObjectId(index));
                StoryProtocol.GetProtocol().EnableGear(index, true);

                Server.GetClientByIndex(index).Character.PlayerShip.isVisible = false;
                SendChangeVisibility(index, Server.GetObjectId(index), Server.GetClientByIndex(index).Character.PlayerShip.isVisible, 0);
                Server.GetClientByIndex(index).Character.PlayerShip.jumpInTime = DateTime.Now.AddSeconds(10);
                break;

            case Request.SetSpeed:
                Client setSpeedClient = Server.GetClientByIndex(index);
                CheckIfVisibleAndSetIfNot(setSpeedClient);
                byte  mode  = br.ReadByte();
                float speed = br.ReadSingle();
                setSpeedClient.Character.PlayerShip.shipMode              = mode;
                setSpeedClient.Character.PlayerShip.shipSpeed             = speed;
                setSpeedClient.Character.PlayerShip.MovementOptions.speed = setSpeedClient.Character.PlayerShip.shipGear == Gear.Regular ? setSpeedClient.Character.PlayerShip.shipSpeed : setSpeedClient.Character.PlayerShip.currentShipStats.BoostSpeed;
                SyncMove(index, SpaceEntityType.Player, Server.GetObjectId(index));
                break;

            case Request.SetGear:
                Client setGearClient = Server.GetClientByIndex(index);
                CheckIfVisibleAndSetIfNot(setGearClient);
                setGearClient.Character.PlayerShip.shipGear = (Gear)br.ReadByte();
                setGearClient.Character.PlayerShip.MovementOptions.speed = setGearClient.Character.PlayerShip.shipGear == Gear.Regular ? setGearClient.Character.PlayerShip.shipSpeed : setGearClient.Character.PlayerShip.currentShipStats.BoostSpeed;
                SyncMove(index, SpaceEntityType.Player, Server.GetObjectId(index));
                break;

            case Request.WASD:
                Client wasdClient = Server.GetClientByIndex(index);
                Sector wasdServer = Server.GetSectorById(wasdClient.Character.PlayerShip.sectorId);
                CheckIfVisibleAndSetIfNot(wasdClient);
                wasdClient.Character.PlayerShip.qweasd.Bitmask = br.ReadByte();

                wasdClient.Character.PlayerShip.ManeuverController.AddManeuver(new TurnManeuver(ManeuverType.Turn, wasdServer.Tick.Current.value, wasdClient.Character.PlayerShip.qweasd, wasdClient.Character.PlayerShip.MovementOptions));

                SyncMove(index, SpaceEntityType.Player, Server.GetObjectId(index));
                break;

            case Request.MoveToDirection:
                Client directionalClient = Server.GetClientByIndex(index);
                Sector directionalServer = Server.GetSectorById(directionalClient.Character.PlayerShip.sectorId);
                CheckIfVisibleAndSetIfNot(directionalClient);
                directionalClient.Character.PlayerShip.direction = br.ReadEuler();

                directionalClient.Character.PlayerShip.ManeuverController.AddManeuver(new DirectionalManeuver(ManeuverType.Directional, directionalServer.Tick.Current.value, directionalClient.Character.PlayerShip.direction, directionalClient.Character.PlayerShip.MovementOptions));

                SyncMove(index, SpaceEntityType.Player, Server.GetObjectId(index));
                break;

            case Request.MoveToDirectionWithoutRoll:
                Client directionalWrClient = Server.GetClientByIndex(index);
                Sector directionalWrServer = Server.GetSectorById(directionalWrClient.Character.PlayerShip.sectorId);
                CheckIfVisibleAndSetIfNot(directionalWrClient);
                directionalWrClient.Character.PlayerShip.direction = br.ReadEuler();

                directionalWrClient.Character.PlayerShip.ManeuverController.AddManeuver(new DirectionalWithoutRollManeuver(ManeuverType.DirectionalWithoutRoll, directionalWrServer.Tick.Current.value, directionalWrClient.Character.PlayerShip.direction, directionalWrClient.Character.PlayerShip.MovementOptions));

                SyncMove(index, SpaceEntityType.Player, Server.GetObjectId(index));
                break;

            case Request.QWEASD:
                Client qweasdClient = Server.GetClientByIndex(index);
                Sector qweasdServer = Server.GetSectorById(qweasdClient.Character.PlayerShip.sectorId);
                CheckIfVisibleAndSetIfNot(qweasdClient);
                qweasdClient.Character.PlayerShip.qweasd.Bitmask = br.ReadByte();

                qweasdClient.Character.PlayerShip.ManeuverController.AddManeuver(new TurnQweasdManeuver(ManeuverType.TurnQweasd, qweasdServer.Tick.Current.value, qweasdClient.Character.PlayerShip.qweasd, qweasdClient.Character.PlayerShip.MovementOptions));

                SyncMove(index, SpaceEntityType.Player, Server.GetObjectId(index));
                break;

            case Request.Dock:
                uint  objId = br.ReadUInt32();
                float delay = br.ReadSingle();
                SendDock(index, delay);
                break;

            case Request.Quit:
                Client quitClient = Server.GetClientByIndex(index);
                quitClient.Character.PlayerShip.isSpawned = false;
                if (quitClient.Character.PlayerShip.requestedJumpSectorId == -1)
                {
                    quitClient.Character.GameLocation = GameLocation.Room;
                }
                else
                {
                    quitClient.Character.PlayerShip.requestedJumpSectorId = -1;
                    Database.Database.SaveSector(quitClient.playerId.ToString(), quitClient.Character.PlayerShip.sectorId);
                    quitClient.Character.GameLocation         = GameLocation.Space;
                    quitClient.Character.PlayerShip.shipGear  = Gear.Regular;
                    quitClient.Character.PlayerShip.shipSpeed = 0;
                }
                break;

            case Request.Jump:
                Client jumpClient = Server.GetClientByIndex(index);
                CheckIfVisibleAndSetIfNot(jumpClient);

                SendJump(index, br.ReadUInt32(), true);
                break;

            case Request.StopJump:
                Client stopJumpClient = Server.GetClientByIndex(index);
                if (stopJumpClient.Character.PlayerShip.requestedJumpSectorId != -1)
                {
                    SendStopJump(index);
                }
                break;

            default:
                Log.Add(LogSeverity.ERROR, string.Format("Unknown msgType \"{0}\" on {1}Protocol.", (Request)msgType, protocolID));
                break;
            }
        }