示例#1
0
        public bool UpdateCharacterProfile(int characterId, PlayerSaveStateData state)
        {
            // Quick exit if values are invalid
            if (characterId == PlayerSaveState.NO_CHARACTER_ID || state == null)
            {
                return(false);
            }
            try
            {
                if (isDbConnectionValid == false)
                {
                    Initialize();
                }

                userUpdateCharacterProfile.Parameters["character_id"].Value = characterId;
                userUpdateCharacterProfile.Parameters["state"].Value        = state.state;

                return(userUpdateCharacterProfile.ExecuteNonQuery() == 1);
            }
            catch (Exception msg)
            {
                // something went wrong, and you wanna know why
                Console.Write("Exception {0}\n", msg);
                return(false);
            }
        }
示例#2
0
 public override void Read(BinaryReader reader)
 {
     base.Read(reader);
     // TODO: Non-alloc version of this
     state = new PlayerSaveStateData();
     state.Read(reader);
 }
示例#3
0
 public override void Dispose()
 {
     if (state != null)
     {
         state = null;
     }
 }
示例#4
0
        public void SendUpdateCharacter(int characterId, PlayerSaveStateData state)
        {
            Console.WriteLine("send update char: characterId: {0}, state: {1}", characterId, state);
            ProfileUpdateCharacter packet = (ProfileUpdateCharacter)IntrepidSerialize.TakeFromPool(PacketType.ProfileUpdateCharacter);

            packet.characterId = characterId;
            packet.state       = state;
            socket.Send(packet);
        }
示例#5
0
    public override void CopyFrom(BasePacket packet)
    {
        base.CopyFrom(packet);
        var typedPacket = (UpdatePlayerSaveStatePacket)packet;

        // TODO: Non-alloc version of this
        state = new PlayerSaveStateData();
        state.CopyFrom(typedPacket.state);
    }
示例#6
0
 public void CopyFrom(PlayerSaveState other)
 {
     accountId   = other.accountId;
     characterId = other.accountId;
     name        = other.name;
     // TODO: Non-alloc version of this
     state = new PlayerSaveStateData();
     state.CopyFrom(other.state);
 }
示例#7
0
 public void Read(BinaryReader reader)
 {
     accountId   = reader.ReadInt32();
     characterId = reader.ReadInt32();
     name        = reader.ReadString();
     // TODO: Non-alloc version of this
     state = new PlayerSaveStateData();
     state.Read(reader);
 }
示例#8
0
        public override void CopyFrom(BasePacket packet)
        {
            base.CopyFrom(packet);
            var typedPacket = (ProfileUpdateCharacter)packet;

            characterId = typedPacket.characterId;
            // TODO: Non-alloc version of this
            state = new PlayerSaveStateData();
            state.CopyFrom(typedPacket.state);
        }
示例#9
0
        public override void CopyFrom(BasePacket packet)
        {
            base.CopyFrom(packet);
            var typedPacket = (ProfileCreateCharacterRequest)packet;

            accountId     = typedPacket.accountId;
            productName   = typedPacket.productName;
            characterName = typedPacket.characterName;
            // TODO: Non-alloc version of this
            state = new PlayerSaveStateData();
            state.CopyFrom(typedPacket.state);
        }
示例#10
0
        public override void Read(BinaryReader reader)
        {
            base.Read(reader);
            accountId = reader.ReadInt32();
            productName.Read(reader);
            characterName.Read(reader);

            /*  productName = reader.ReadString();
            *  characterName = reader.ReadString();*/
            // TODO: Non-alloc version of this
            state = new PlayerSaveStateData();
            state.Read(reader);
        }
示例#11
0
 public void Write(BinaryWriter writer)
 {
     writer.Write(accountId);
     writer.Write(characterId);
     if (name == null)
     {
         name = string.Empty;
     }
     writer.Write(name);
     if (state == null)
     {
         // TODO: Non-alloc version of this
         state = new PlayerSaveStateData();
     }
     state.Write(writer);
 }
示例#12
0
        static void Main(string[] args)
        {
            CommonLibrary.Parser.ParseCommandLine(args);
            Int64 applicationId = CommonLibrary.Parser.ApplicationId;

            if (applicationId == 0)
            {
                applicationId = Network.Utils.GetIPBasedApplicationId();
            }
            float  sleepTime = 1000.0f / (float)CommonLibrary.Parser.FPS;
            string ipAddr    = CommonLibrary.Parser.ipAddr;

            ushort port = 11002;
            TestLoginController game = new TestLoginController(ipAddr, port);
            ConsoleKey          key;

            do
            {
                while (!Console.KeyAvailable)
                {
                }
                key = Console.ReadKey(true).Key;
                if (key == ConsoleKey.UpArrow)
                {
                    Console.WriteLine("Send request set to succeed");
                    game.SendLoginRequest("mickey", "password", "hungry hippos");
                }
                if (key == ConsoleKey.DownArrow)
                {
                    Console.WriteLine("Send request set to fail");
                    game.SendLoginRequest("mickey", "password1", "hungry hippos");
                }
                if (key == ConsoleKey.RightArrow)
                {
                    Console.WriteLine("Send request set to fail");
                    game.SendLoginRequest("tim", "password", "hungry hippos");
                }
                if (key == ConsoleKey.LeftArrow)
                {
                    Console.WriteLine("Send request set to fail");
                    game.SendLoginRequest("mickey", "password", "hungry hippos 123");
                }
                if (key == ConsoleKey.E)
                {
                    Console.WriteLine("Drop DB");
                    game.SendLoginRequest("mickey", "password DROP TABLE users;", "hungry hippos 123");
                }
                if (key == ConsoleKey.S)
                {
                    Console.WriteLine("Special characters");
                    game.SendLoginRequest("mickey", "password", "'%s' '\n' p @pass #1 pass");
                }
                if (key == ConsoleKey.C)
                {
                    Console.WriteLine("Profile");
                    game.SendLoginRequest("chris", "password", "hungry hippos");
                }
                if (key == ConsoleKey.I)
                {
                    Console.WriteLine("Create character");
                    var state = new PlayerSaveStateData();
                    state.state = "{}";
                    game.SendCreateCharacter(2, "hungry hippos", "TestChar", state);
                }
                if (key == ConsoleKey.U)
                {
                    Console.WriteLine("Update character");
                    var state = new PlayerSaveStateData();
                    state.state = "{\"test\":\"data\"}";
                    game.SendUpdateCharacter(7, state);
                }
                if (key == ConsoleKey.M)
                {
                    Console.WriteLine("Major list of crap to send");
                    var test = new Packets.TestPacket();
                    Packets.TestDataBlob blob1 = new Packets.TestDataBlob(1, 2);
                    Packets.TestDataBlob blob2 = new Packets.TestDataBlob(3, 4);
                    Packets.TestDataBlob blob3 = new Packets.TestDataBlob(5, 6);
                    test.listOfBlobs.listOfSerializableItems.Add(blob1);
                    test.listOfBlobs.listOfSerializableItems.Add(blob2);
                    test.listOfBlobs.listOfSerializableItems.Add(blob3);
                    //test.state = "{\"test\":\"data\"}";
                    game.Send(test);
                }
            } while (key != ConsoleKey.Escape);
            game.Disconnect();
        }
示例#13
0
        public void SendCreateCharacter(int accountId, string productName, string characterName, PlayerSaveStateData state)
        {
            Console.WriteLine("send create char: accountId: {0}, productName: {1}, charName: {2}, state: {3}", accountId, productName, characterName, state);
            ProfileCreateCharacterRequest packet = (ProfileCreateCharacterRequest)IntrepidSerialize.TakeFromPool(PacketType.ProfileCreateCharacterRequest);

            packet.accountId = accountId;
            packet.productName.Copy(productName);
            packet.characterName.Copy(characterName);
            packet.state = state;
            socket.Send(packet);
        }
示例#14
0
        public int CreateCharacterProfile(int accountId, string productName, string characterName, PlayerSaveStateData state)
        {
            int productId = GetProductIdFromName(StringUtils.Sanitize(productName, false));

            // Quick exit if values are invalid
            if (accountId == -1 || characterName.Length == 0 || state == null || productId == -1)
            {
                return(PlayerSaveState.NO_CHARACTER_ID);
            }
            try
            {
                if (isDbConnectionValid == false)
                {
                    Initialize();
                }

                // user_id in the db is the accountId
                userInsertCharacterProfile.Parameters["user_id"].Value    = accountId;
                userInsertCharacterProfile.Parameters["product_id"].Value = productId;
                userInsertCharacterProfile.Parameters["name"].Value       = characterName;
                userInsertCharacterProfile.Parameters["state"].Value      = state.state;

                if (userInsertCharacterProfile.ExecuteNonQuery() != 1)
                {
                    // Something went wrong
                    return(PlayerSaveState.NO_CHARACTER_ID);
                }
                // Grab the character_id
                // TODO: Wrap this up in a stored proc - this current approach only works as we only have one
                // login server, and we block on each query made
                userGetCharacterProfile.Parameters["user_id"].Value    = accountId; // user_id in the db is the accoountId
                userGetCharacterProfile.Parameters["product_id"].Value = productId;
                return((int)userGetCharacterProfile.ExecuteScalar());
            }
            catch (Exception msg)
            {
                // something went wrong, and you wanna know why
                Console.Write("Exception {0}\n", msg);
                return(PlayerSaveState.NO_CHARACTER_ID);
            }
        }
示例#15
0
 public void CopyFrom(PlayerSaveStateData other)
 {
     state = other.state;
 }