Example #1
0
        private void ProcessProfileCreateCharacterRequest(RequestSetup requestInProcess)
        {
            ProfileCreateCharacterRequest request = requestInProcess.request as ProfileCreateCharacterRequest;
            int characterId = accountQuerier.CreateCharacterProfile(
                request.accountId,
                request.productName.MakeString(),
                request.characterName.MakeString(),
                request.state);

            if (characterId == -1)
            {
                // We could return a result here - however the game server could request a load, and when that fails it'll know something is up
                Console.Error.WriteLine("Failed to create new character: accountId: {0}, productName: {1}, characterName: {2}, state: {3}",
                                        request.accountId, request.productName, request.characterName, request.state);
            }

            ProfileCreateCharacterResponse response = (ProfileCreateCharacterResponse)IntrepidSerialize.TakeFromPool(PacketType.ProfileCreateCharacterResponse);

            response.accountId   = request.accountId;
            response.characterId = characterId;

            ConnectionState cs = connections[requestInProcess.connectionId];

            cs.Send(response);
        }
Example #2
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);
        }
Example #3
0
        private void CreateFakeResponse(BasePacket packet)
        {
            // Fake a response
            ProfileCreateCharacterRequest request = packet as ProfileCreateCharacterRequest;

            if (request != null)
            {
                ProfileCreateCharacterResponse response = (ProfileCreateCharacterResponse)IntrepidSerialize.TakeFromPool(PacketType.ProfileCreateCharacterResponse);
                response.accountId   = request.accountId;
                response.characterId = fakeCharacterId++;
                lock (packetLock)
                {
                    incomingPackets.Enqueue(response);
                }
            }
        }
Example #4
0
    private void UpdateSaveStatePacket(UpdatePlayerSaveStatePacket packet)
    {
        // We pass these create / update requests to the profile server we're connected to
        if (saveState.characterId == PlayerSaveState.NO_CHARACTER_ID)
        {
            ProfileCreateCharacterRequest request = (ProfileCreateCharacterRequest)IntrepidSerialize.TakeFromPool(PacketType.ProfileCreateCharacterRequest);
            request.accountId     = saveState.accountId;
            request.productName   = "hungry hippos"; //TODO: configure this!
            request.characterName = saveState.name;  // TODO: Need to have some kind of create character packet where they can specify name
            request.state         = packet.state;
            Server.SendToProfileServer(request);
        }
        else
        {
            ProfileUpdateCharacter request = (ProfileUpdateCharacter)IntrepidSerialize.TakeFromPool(PacketType.ProfileUpdateCharacter);
            request.characterId = saveState.characterId;
            request.state       = packet.state;
            Server.SendToProfileServer(request);
        }

        // We assume the state will be created / saved
        saveState.state = packet.state;
    }