Esempio n. 1
0
 public override void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_InsideMesh               = new SerializedComponent(assetFile, stream);
     m_MiddleMesh               = new SerializedComponent(assetFile, stream);
     m_OutsideMesh              = new SerializedComponent(assetFile, stream);
     m_ArrowMesh                = new SerializedComponent(assetFile, stream);
     m_CloseArrowMesh           = new SerializedComponent(assetFile, stream);
     m_FarArrowMesh             = new SerializedComponent(assetFile, stream);
     m_insideTexture            = new SerializedComponent(assetFile, stream);
     m_middleTexture            = new SerializedComponent(assetFile, stream);
     m_outsideTexture           = new SerializedComponent(assetFile, stream);
     m_arrowTexture             = new SerializedComponent(assetFile, stream);
     m_closeArrowTexture        = new SerializedComponent(assetFile, stream);
     m_farArrowTexture          = new SerializedComponent(assetFile, stream);
     m_chasingDiamonds          = new SerializedArray <SerializedComponent>(assetFile, stream);
     m_chasingInnerRing         = new SerializedComponent(assetFile, stream);
     m_chasingOuterRing         = new SerializedComponent(assetFile, stream);
     m_chasingArrow             = new SerializedComponent(assetFile, stream);
     m_chasingDiamondTexture    = new SerializedComponent(assetFile, stream);
     m_chasingInnerRingTexture  = new SerializedComponent(assetFile, stream);
     m_chasingOuterRingTexture  = new SerializedComponent(assetFile, stream);
     m_chasingArrowTexture      = new SerializedComponent(assetFile, stream);
     m_KnockbackMesh            = new SerializedComponent(assetFile, stream);
     m_animationController      = new SerializedComponent(assetFile, stream);
     m_movementContainer        = new SerializedComponent(assetFile, stream);
     m_chasingContainer         = new SerializedComponent(assetFile, stream);
     m_knockbackContainer       = new SerializedComponent(assetFile, stream);
     m_chasingDiamondsContainer = new SerializedComponent(assetFile, stream);
     endPiece  = new SerializedComponent(assetFile, stream);
     linePiece = new SerializedComponent(assetFile, stream);
 }
Esempio n. 2
0
        public WorkerTask(int taskId, int workerId, int[] items)
        {
            TaskId = taskId;
            var arr = new SerializedArray()
            {
                Items = items
            };

            client = new TcpClient();
            client.Connect(IPAddress.Loopback, workerId);
            var bf = new BinaryFormatter();

            thread = new Thread(new ThreadStart(() =>
            {
                var startTime = DateTime.Now;
                bf.Serialize(client.GetStream(), arr);
                var result = (SerializedArray)bf.Deserialize(client.GetStream());
                client.Close();
                client.Dispose();
                var endedTime      = DateTime.Now;
                TimeSpan ts        = endedTime.Subtract(startTime);
                string elapsedTime = $"{ts.Seconds}.{ts.Milliseconds}";
                Callback?.Invoke(workerId, taskId, elapsedTime, result.Items);
            }));
        }
Esempio n. 3
0
 public void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_effectName                  = stream.ReadString32();
     m_duration                    = stream.ReadInt32();
     m_maxStackSize                = stream.ReadInt32();
     m_damagePerTurn               = stream.ReadInt32();
     m_healingPerTurn              = stream.ReadInt32();
     m_healingType                 = (HealingType)stream.ReadInt32();
     m_perTurnHitDelayTurns        = stream.ReadInt32();
     m_absorbAmount                = stream.ReadInt32();
     m_nextTurnAbsorbAmount        = stream.ReadInt32();
     m_dontEndEarlyOnShieldDeplete = stream.ReadBoolean();
     stream.AlignTo();
     m_damagePerMoveSquare                  = stream.ReadInt32();
     m_healPerMoveSquare                    = stream.ReadInt32();
     m_techPointLossPerMoveSquare           = stream.ReadInt32();
     m_techPointGainPerMoveSquare           = stream.ReadInt32();
     m_techPointChangeOnStart               = stream.ReadInt32();
     m_techPointGainPerTurn                 = stream.ReadInt32();
     m_techPointLossPerTurn                 = stream.ReadInt32();
     m_invisBreakMode                       = (InvisibilityBreakMode)stream.ReadInt32();
     m_removeInvisibilityOnLastResolveStart = stream.ReadBoolean();
     stream.AlignTo();
     m_removeRevealedOnLastResolveStart = stream.ReadBoolean();
     stream.AlignTo();
     m_statMods           = new SerializedArray <AbilityStatMod>(assetFile, stream);
     m_statusChanges      = new SerializedArray <StatusType>(assetFile, stream);
     m_statusDelayMode    = (StatusDelayMode)stream.ReadInt32();
     m_endTriggers        = new SerializedArray <EffectEndTag>(assetFile, stream);
     m_sequencePrefabs    = new SerializedVector <SerializedComponent>(assetFile, stream);
     m_tickSequencePrefab = new SerializedComponent(assetFile, stream);
 }
Esempio n. 4
0
 public void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_spawnerTitle            = stream.ReadString32();
     m_actorPrefab             = new SerializedComponent(assetFile, stream);
     m_characterResourceLink   = new SerializedComponent(assetFile, stream);
     m_actorBrain              = new SerializedComponent(assetFile, stream);
     m_spawnPoint              = new SerializedComponent(assetFile, stream);
     m_destination             = new SerializedComponent(assetFile, stream);
     m_initialSpawnLookAtPoint = new SerializedComponent(assetFile, stream);
     m_spawnTurn          = stream.ReadInt32();
     m_respawnTime        = stream.ReadInt32();
     m_spawnScriptIndex   = stream.ReadInt32();
     m_despawnScriptIndex = stream.ReadInt32();
     m_skinIndex          = stream.ReadInt32();
     m_patternIndex       = stream.ReadInt32();
     m_colorIndex         = stream.ReadInt32();
     m_team = (Team)stream.ReadInt32();
     m_actorNameOverride = stream.ReadString32();
     m_isPlayer          = stream.ReadBoolean();
     stream.AlignTo();
     m_activationsOnDeath = new SerializedArray <ActivatableObject>(assetFile, stream);
     m_activationsOnSpawn = new SerializedArray <ActivatableObject>(assetFile, stream);
     m_applyEffectOnNPC   = stream.ReadBoolean();
     stream.AlignTo();
     m_effectOnNPC        = new StandardActorEffectData(assetFile, stream);
     m_tagsToApplyToActor = new SerializedArray <string>(assetFile, stream);
     m_actor = new SerializedComponent(assetFile, stream);
     m_id    = stream.ReadInt32();
 }
Esempio n. 5
0
 public void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_conditionString        = stream.ReadString32();
     m_PointName              = stream.ReadString32();
     m_conditions_anyMet      = new SerializedArray <PointCondition>(assetFile, stream);
     m_conditions_allRequired = new SerializedArray <PointCondition>(assetFile, stream);
     m_conditions_noneAllowed = new SerializedArray <PointCondition>(assetFile, stream);
 }
Esempio n. 6
0
 public void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_pointsMustBe      = (PointRelationship)stream.ReadInt32();
     threshold           = stream.ReadInt32();
     subtractEnemyPoints = stream.ReadBoolean();
     stream.AlignTo();
     whenRelationship = (WhenRelationship)stream.ReadInt32();
     m_CTF_conditions = new SerializedArray <CaptureTheFlag.CTF_VictoryCondition>(assetFile, stream);
     m_CTC_conditions = new SerializedArray <CollectTheCoins.CollectTheCoins_VictoryCondition>(assetFile, stream);
 }
Esempio n. 7
0
 public void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_effect                 = new StandardEffectInfo(assetFile, stream);
     m_credits                = stream.ReadInt32();
     m_healing                = stream.ReadInt32();
     m_damage                 = stream.ReadInt32();
     m_techPoints             = stream.ReadInt32();
     m_permanentStatMods      = new SerializedArray <AbilityStatMod>(assetFile, stream);
     m_permanentStatusChanges = new SerializedArray <StatusType>(assetFile, stream);
     m_sequenceToPlay         = new SerializedComponent(assetFile, stream); // class [UnityEngine]UnityEngine.GameObject
 }
Esempio n. 8
0
 public override void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_script                               = new SerializedArray <SinglePlayerState>(assetFile, stream);
     m_forbiddenSquares                     = new BoardRegion(assetFile, stream);
     m_activationsOnForbiddenPath           = new SerializedArray <ActivatableObject>(assetFile, stream);
     m_activationsOnFailedToShootAndMove    = new SerializedArray <ActivatableObject>(assetFile, stream);
     m_activationsOnFailedToUseAllAbilities = new SerializedArray <ActivatableObject>(assetFile, stream);
     m_initialCameraRotationTarget          = new SerializedComponent(assetFile, stream);
     m_chatTextOnLowHealth                  = new SerializedArray <SinglePlayerScriptedChat>(assetFile, stream);
     m_chatTextAtEndOfMatch                 = new SerializedArray <SinglePlayerScriptedChat>(assetFile, stream);
 }
Esempio n. 9
0
 public void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_stateTitle                = stream.ReadString32();
     m_allowedAbilities          = new SerializedArray <int>(assetFile, stream);
     m_allowedDestinations       = new BoardRegion(assetFile, stream);
     m_advanceScriptDestinations = new BoardRegion(assetFile, stream);
     m_respawnDestinations       = new BoardRegion(assetFile, stream);
     m_allowedTargets            = new BoardRegion(assetFile, stream);
     m_mustTargetNearCenter      = stream.ReadBoolean();
     stream.AlignTo();
     m_onlyAllowWaypointMovement = stream.ReadBoolean();
     stream.AlignTo();
     m_rightClickHighlight        = new BoardRegion(assetFile, stream);
     m_rightClickText             = stream.ReadString32();
     m_rightClickHeight           = stream.ReadSingle();
     m_shiftRightClickHighlight   = new BoardRegion(assetFile, stream);
     m_shiftRightClickText        = stream.ReadString32();
     m_shiftRightClickHeight      = stream.ReadSingle();
     m_leftClickHighlight         = new BoardRegion(assetFile, stream);
     m_leftClickText              = stream.ReadString32();
     m_leftClickHeight            = stream.ReadSingle();
     m_minAbilityTargetsForAiming = stream.ReadInt32();
     m_bannerText                  = stream.ReadString32();
     m_tutorialBoxText             = new TextRegion(assetFile, stream);
     m_tutorialBoxText2            = new TextRegion(assetFile, stream);
     m_tutorialBoxText3            = new TextRegion(assetFile, stream);
     m_tutorialCameraMovementText  = new TextRegion(assetFile, stream);
     m_tutorialCameraRotationText  = new TextRegion(assetFile, stream);
     m_errorStringOnForbiddenPath  = stream.ReadString32();
     m_cameraRotationTarget        = new SerializedComponent(assetFile, stream);
     m_advanceAfterSeconds         = stream.ReadSingle();
     m_minPlayerHitPoints          = stream.ReadInt32();
     m_minAllyHitPoints            = stream.ReadInt32();
     m_audioEventOnPreEnter        = stream.ReadString32();
     m_audioEventOnEnter           = stream.ReadString32();
     m_audioEventOnExit            = stream.ReadString32();
     m_chatTextOnEnter             = new SerializedArray <SinglePlayerScriptedChat>(assetFile, stream);
     m_tutorialVideoPreviewOnEnter = stream.ReadString32();
     m_markedForAdvanceState       = stream.ReadBoolean();
     stream.AlignTo();
     m_stateIndex                    = stream.ReadInt32();
     m_startTime                     = stream.ReadSingle();
     m_tags                          = new SerializedArray <SinglePlayerTag>(assetFile, stream);
     m_activationsOnEnter            = new SerializedArray <ActivatableObject>(assetFile, stream);
     m_activationsOnExit             = new SerializedArray <ActivatableObject>(assetFile, stream);
     m_uiActivationsOnEnter          = new SerializedArray <ActivatableUI>(assetFile, stream);
     m_uiActivationsOnExit           = new SerializedArray <ActivatableUI>(assetFile, stream);
     m_npcsToSpawnOnEnter            = new SerializedArray <string>(assetFile, stream);
     m_npcsToDespawnOnEnter          = new SerializedArray <string>(assetFile, stream);
     m_advanceScriptIfActorDies      = (ActorDiesTrigger)stream.ReadInt32();
     m_advanceScriptIfActorDiesCount = stream.ReadInt32();
     m_actorDeaths                   = stream.ReadInt32();
 }
Esempio n. 10
0
 public override void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_energyGainMultiplier          = stream.ReadSingle();
     m_energyGainMultInterval        = new IntervalDef(assetFile, stream);
     m_damageMultiplier              = stream.ReadSingle();
     m_damageMultInterval            = new IntervalDef(assetFile, stream);
     m_healingMultiplier             = stream.ReadSingle();
     m_healingMultInterval           = new IntervalDef(assetFile, stream);
     m_absorbMultiplier              = stream.ReadSingle();
     m_absorbMultInterval            = new IntervalDef(assetFile, stream);
     m_cooldownSpeedAdjustment       = stream.ReadInt32();
     m_cooldownTimeAdjustment        = stream.ReadInt32();
     m_cooldownMultiplier            = stream.ReadSingle();
     m_powerupRefreshSpeedAdjustment = stream.ReadInt32();
     m_powerupDurationAdjustment     = stream.ReadInt32();
     m_alwaysOnStatuses              = new SerializedArray <StatusInterval>(assetFile, stream);
     m_statusSuppression             = new SerializedArray <StatusInterval>(assetFile, stream);
     m_passiveEnergyRegenMultiplier  = stream.ReadSingle();
     m_passiveHpRegenMultiplier      = stream.ReadSingle();
     m_useEnergizedOverride          = stream.ReadBoolean();
     stream.AlignTo();
     m_energizedEnergyGainMod    = new AbilityModPropertyInt(assetFile, stream);
     m_useSlowEnergyGainOverride = stream.ReadBoolean();
     stream.AlignTo();
     m_slowEnergyGainEnergyGainMod = new AbilityModPropertyInt(assetFile, stream);
     m_useHasteOverride            = stream.ReadBoolean();
     stream.AlignTo();
     m_hasteHalfMovementAdjustAmount = stream.ReadInt32();
     m_hasteFullMovementAdjustAmount = stream.ReadInt32();
     m_hasteMovementMultiplier       = stream.ReadSingle();
     m_useSlowOverride = stream.ReadBoolean();
     stream.AlignTo();
     m_slowHalfMovementAdjustAmount = stream.ReadInt32();
     m_slowFullMovementAdjustAmount = stream.ReadInt32();
     m_slowMovementMultiplier       = stream.ReadSingle();
     m_useEmpoweredOverride         = stream.ReadBoolean();
     stream.AlignTo();
     m_empoweredOutgoingDamageMod  = new AbilityModPropertyInt(assetFile, stream);
     m_empoweredOutgoingHealingMod = new AbilityModPropertyInt(assetFile, stream);
     m_empoweredOutgoingAbsorbMod  = new AbilityModPropertyInt(assetFile, stream);
     m_useWeakenedOverride         = stream.ReadBoolean();
     stream.AlignTo();
     m_weakenedOutgoingDamageMod  = new AbilityModPropertyInt(assetFile, stream);
     m_weakenedOutgoingHealingMod = new AbilityModPropertyInt(assetFile, stream);
     m_weakenedOutgoingAbsorbMod  = new AbilityModPropertyInt(assetFile, stream);
     m_useArmoredOverride         = stream.ReadBoolean();
     stream.AlignTo();
     m_armoredIncomingDamageMod = new AbilityModPropertyInt(assetFile, stream);
     m_useVulnerableOverride    = stream.ReadBoolean();
     stream.AlignTo();
     m_vulnerableDamageMultiplier = stream.ReadSingle();
     m_vulnerableDamageFlatAdd    = stream.ReadInt32();
 }
Esempio n. 11
0
        static void Main(string[] args)
        {
            int port = GetAvailablePort();

            var listener = new TcpListener(IPAddress.Loopback, port);

            listener.Start();

            var thread = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    TcpClient client      = listener.AcceptTcpClient();
                    BinaryFormatter bf    = new BinaryFormatter();
                    SerializedArray array = (SerializedArray)bf.Deserialize(client.GetStream());
                    WriteLine("");
                    WriteLine("Recebido!");
                    array.Items.PrintItems();
                    array.Items.Sort();
                    WriteLine("Ordenado!");
                    array.Items.PrintItems();
                    bf.Serialize(client.GetStream(), array);
                }
            }));

            thread.Start();
            WriteLine($"Started in port {port}");
            Console.ReadKey();
            thread.Interrupt();
            WriteLine($"Stopped!");

            string text = File.ReadAllText(Constants.PATH_FILE_WORKERS);

            string[] jobs = text.Split(",")
                            .Where(p => !string.IsNullOrWhiteSpace(p) && p != $"{port}")
                            .ToArray();
            File.WriteAllText(Constants.PATH_FILE_WORKERS, $"{string.Join(",", jobs)}");
            WriteLine("Porta liberada");
        }
Esempio n. 12
0
 public virtual void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_quads = new SerializedArray <BoardQuad>(assetFile, stream);
 }
Esempio n. 13
0
 public override void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_heroSpoils   = new SerializedArray <SerializedComponent>(assetFile, stream);
     m_minionSpoils = new SerializedArray <SerializedComponent>(assetFile, stream);
 }
Esempio n. 14
0
 public override void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_displayName   = stream.ReadString32();
     m_region        = new BoardRegion(assetFile, stream);
     m_startingState = (State)stream.ReadInt32();
     m_progressType  = (ControlProgressType)stream.ReadInt32();
     m_stayControlledUntilOtherTeamCaptures = stream.ReadBoolean();
     stream.AlignTo();
     m_resetProgressOnceCaptured = stream.ReadBoolean();
     stream.AlignTo();
     m_resetProgressOnceDisabled = stream.ReadBoolean();
     stream.AlignTo();
     m_progressNeededForTeamAToCapture   = stream.ReadInt32();
     m_maxTotalProgressForTeamA          = stream.ReadInt32();
     m_maxProgressForTeamAOnceControlled = stream.ReadInt32();
     m_progressNeededForTeamBToCapture   = stream.ReadInt32();
     m_maxTotalProgressForTeamB          = stream.ReadInt32();
     m_maxProgressForTeamBOnceControlled = stream.ReadInt32();
     m_maxProgressChangeInOneTurn        = stream.ReadInt32();
     m_progressDecayPerTurn = stream.ReadInt32();
     m_numVacantTurnsUntilProgressDecays = stream.ReadInt32();
     m_allowIndependentVacancyDecay      = stream.ReadBoolean();
     stream.AlignTo();
     m_turnsLockedAfterCapture             = stream.ReadInt32();
     m_turnsLockedAfterActivated           = stream.ReadInt32();
     m_canContributeProgressWhileContested = stream.ReadBoolean();
     stream.AlignTo();
     m_startingProgress                       = stream.ReadInt32();
     m_controllingTeamGameplay                = new ControlPointGameplay(assetFile, stream);
     m_otherTeamGameplay                      = new ControlPointGameplay(assetFile, stream);
     m_totalObjectivePointsToDispense         = stream.ReadInt32();
     m_disableWhenDispensedLastObjectivePoint = stream.ReadBoolean();
     stream.AlignTo();
     m_controlPointsToActivateOnDisabled   = new SerializedVector <SerializedGameObject>(assetFile, stream);
     m_numRandomControlPointsToActivate    = stream.ReadInt32();
     m_randomActivateTurnsLockedOverride   = stream.ReadInt32();
     m_randomActivateIgnoreIfEverActivated = stream.ReadBoolean();
     stream.AlignTo();
     m_visionGranting        = (VisionGranting)stream.ReadInt32();
     m_visionSeeThroughBrush = stream.ReadBoolean();
     stream.AlignTo();
     m_visionRegionOverride  = new BoardRegion(assetFile, stream);
     m_whenToApplyHealing    = (VisionGranting)stream.ReadInt32();
     m_healPerTurn           = stream.ReadInt32();
     m_healHitSequencePrefab = new SerializedComponent(assetFile, stream);
     m_spawnForMatchingTeams = stream.ReadBoolean();
     stream.AlignTo();
     m_spawnersForController       = new SerializedArray <SerializedGameObject>(assetFile, stream);
     m_autoGenerateBoundaryVisuals = stream.ReadBoolean();
     stream.AlignTo();
     m_boundaryOscillationSpeed         = stream.ReadSingle();
     m_boundaryOscillationHeight        = stream.ReadSingle();
     m_nameplateOverridePosition        = new SerializedComponent(assetFile, stream);
     m_boundaryNeutral                  = new SerializedComponent(assetFile, stream);
     m_boundaryAllied                   = new SerializedComponent(assetFile, stream);
     m_boundaryEnemy                    = new SerializedComponent(assetFile, stream);
     m_boundaryDisabled                 = new SerializedComponent(assetFile, stream);
     m_primaryColor_friendly            = stream.ReadColorRGBA();
     m_primaryColor_hostile             = stream.ReadColorRGBA();
     m_primaryColor_neutral             = stream.ReadColorRGBA();
     m_secondaryColor_contested         = stream.ReadColorRGBA();
     m_secondaryColor_friendlyCapturing = stream.ReadColorRGBA();
     m_secondaryColor_hostileCapturing  = stream.ReadColorRGBA();
     m_uiTextColor_Empty                = stream.ReadColorRGBA();
     m_uiTextColor_Locked               = stream.ReadColorRGBA();
     m_icon = new SerializedComponent(assetFile, stream);
     m_miniMapColorNeutral  = stream.ReadColorRGBA();
     m_miniMapColorAllied   = stream.ReadColorRGBA();
     m_miniMapColorEnemy    = stream.ReadColorRGBA();
     m_miniMapColorDisabled = stream.ReadColorRGBA();
     m_miniMapImage         = new SerializedComponent(assetFile, stream);
     m_currentMinimapColor  = stream.ReadColorRGBA();
     m_captureMessages      = new SerializedArray <CaptureMessage>(assetFile, stream);
 }
Esempio n. 15
0
        private void NegotiateAuthentication(string streamPassword, bool client)
        {
            int oldReadTimeout = baseStream.ReadTimeout;

            baseStream.ReadTimeout = 5000;


            RSACryptoServiceProvider localKeys;
            RSACryptoServiceProvider remoteKey;

            // Generate and send public key
            {
                localKeys = new RSACryptoServiceProvider();
                byte[] publicBlob = localKeys.ExportCspBlob(false);
                baseStream.Write(BitConverter.GetBytes(publicBlob.Length), 0, 4);
                baseStream.Write(publicBlob, 0, publicBlob.Length);
            }

            // Receive remote public key
            try
            {
                byte[] blobLen = new byte[4];
                StreamHelper.ForceReadAll(baseStream, blobLen, 0, 4);

                byte[] remoteBlob = new byte[BitConverter.ToInt32(blobLen, 0)];
                StreamHelper.ForceReadAll(baseStream, remoteBlob, 0, remoteBlob.Length);

                remoteKey = new RSACryptoServiceProvider();
                remoteKey.ImportCspBlob(remoteBlob);
            } catch (Exception) {
                throw new EncryptedNetworkStreamException(EncryptedNetworkStreamException.Reason.NetworkError);
            }

            rsaStream = new RSAStream(baseStream, localKeys, remoteKey);

            AesCryptoServiceProvider aesKey = new AesCryptoServiceProvider();

            aesKey.KeySize = 256;

            // Authenticate client/server
            byte[] passwordHash = MD5.Create().ComputeHash(ASCIIEncoding.UTF8.GetBytes(streamPassword));

            if (client)
            {
                // If we're the client, send the password hash (encrypted)
                rsaStream.Write(passwordHash, 0, 16);

                // Read AES key
                byte[] lenBuffer = new byte[4];
                StreamHelper.ForceReadAll(rsaStream, lenBuffer, 0, 4);

                byte[] aesKeyBuffer = new Byte[BitConverter.ToInt32(lenBuffer, 0)];
                StreamHelper.ForceReadAll(rsaStream, aesKeyBuffer, 0, aesKeyBuffer.Length);

                StreamHelper.ForceReadAll(rsaStream, lenBuffer, 0, 4);

                byte[] aesIVBuffer = new Byte[BitConverter.ToInt32(lenBuffer, 0)];
                StreamHelper.ForceReadAll(rsaStream, aesIVBuffer, 0, aesIVBuffer.Length);

                aesKey.Key = aesKeyBuffer;
                aesKey.IV  = aesIVBuffer;
            }
            else
            {
                // If we're the server, wait for them to send the password (encrypted)
                byte[] receivedPasswordHash = new byte[16];
                StreamHelper.ForceReadAll(rsaStream, receivedPasswordHash, 0, 16);


                if (!passwordHash.SequenceEqual(receivedPasswordHash))
                {
                    throw new EncryptedNetworkStreamException(EncryptedNetworkStreamException.Reason.InvalidAuthentication);
                }

                // Generate/send AES key
                aesKey.GenerateKey();
                aesKey.GenerateIV();

                // Group length and key togeather to lower overhead

                byte[] keyDataBuffer = SerializedArray.ToNetworkBytes(aesKey.Key);
                rsaStream.Write(keyDataBuffer, 0, keyDataBuffer.Length);

                byte[] keyIVBuffer = SerializedArray.ToNetworkBytes(aesKey.IV);
                rsaStream.Write(keyIVBuffer, 0, keyIVBuffer.Length);
            }

            aesStream = new AESStream(baseStream, aesKey);

            baseStream.ReadTimeout = oldReadTimeout;
        }
Esempio n. 16
0
 public override void DeserializeAsset(AssetFile assetFile, StreamReader stream)
 {
     m_diagonalMovement    = (GameplayData.DiagonalMovement)stream.ReadInt32();
     m_movementMaximumType = (GameplayData.MovementMaximumType)stream.ReadInt32();
     m_abilityRangeType    = (GameplayData.AbilityRangeType)stream.ReadInt32();
     m_showTextForPowerUps = stream.ReadBoolean();
     stream.AlignTo();
     m_coverProtectionAngle         = stream.ReadSingle();
     m_coverProtectionDmgMultiplier = stream.ReadSingle();
     m_coverMinDistance             = stream.ReadSingle();
     m_coverShader = new SerializedComponent(assetFile, stream);
     m_recentlySpawnedBonusMovement   = stream.ReadInt32();
     m_recentlyRespawnedBonusMovement = stream.ReadInt32();
     m_recentlySpawnedDuration        = stream.ReadInt32();
     m_recentlyRespawnedDuration      = stream.ReadInt32();
     m_gravity              = stream.ReadSingle();
     m_itemSlots            = stream.ReadInt32();
     m_creditsPerTurn       = stream.ReadInt32();
     m_startingCredits      = stream.ReadInt32();
     m_creditsPerPlayerKill = stream.ReadInt32();
     m_creditBonusFractionPerExtraPlayer = stream.ReadSingle();
     m_playerBountyCountsParticipation   = stream.ReadBoolean();
     stream.AlignTo();
     m_creditsPerMinionKill            = stream.ReadInt32();
     m_minionBountyCountsParticipation = stream.ReadBoolean();
     stream.AlignTo();
     m_participationlessBountiesGoToTeam = stream.ReadBoolean();
     stream.AlignTo();
     m_capturePointsPerTurn               = stream.ReadInt32();
     m_distanceCanSeeIntoBrush            = stream.ReadSingle();
     m_brushDisruptionTurns               = stream.ReadInt32();
     m_unsuppressInvisibilityOnEndOfPhase = stream.ReadBoolean();
     stream.AlignTo();
     m_proximityBasedInvisibilityMinDistance      = stream.ReadSingle();
     m_blindEnemyBreaksProximityBasedInvisibility = stream.ReadBoolean();
     stream.AlignTo();
     m_recallAllowed = stream.ReadBoolean();
     stream.AlignTo();
     m_recallOnlyWhenOutOfCombat = stream.ReadBoolean();
     stream.AlignTo();
     m_recallIncomingDamageMultiplier = stream.ReadSingle();
     m_turnsAbilitiesUnlock           = new SerializedArray <int>(assetFile, stream);
     m_turnCatalystsUnlock            = stream.ReadInt32();
     m_disableAbilitiesOnRespawn      = stream.ReadBoolean();
     stream.AlignTo();
     m_movementAllowedOnRespawn          = (Ability.MovementAdjustment)stream.ReadInt32();
     m_resolveDamageBetweenAbilityPhases = stream.ReadBoolean();
     stream.AlignTo();
     m_resolveDamageAfterEvasion = stream.ReadBoolean();
     stream.AlignTo();
     m_resolveDamageImmediatelyDuringMovement = stream.ReadBoolean();
     stream.AlignTo();
     m_keepTechPointsOnRespawn = stream.ReadBoolean();
     stream.AlignTo();
     m_enableItemGUI = stream.ReadBoolean();
     stream.AlignTo();
     m_npcsShowTargeters = stream.ReadBoolean();
     stream.AlignTo();
     m_showActorAbilityCooldowns = stream.ReadBoolean();
     stream.AlignTo();
     m_maximumPositionX = stream.ReadSingle();
     m_minimumPositionX = stream.ReadSingle();
     m_maximumPositionZ = stream.ReadSingle();
     m_minimumPositionZ = stream.ReadSingle();
 }