Esempio n. 1
0
        /// <summary>
        ///     Checks if gameheart.
        /// </summary>
        /// <param name="p">The player</param>
        /// <returns>Is the player is gameheartish.</returns>
        protected bool CheckIfGameheart(Player p)
        {
            if (p.CurrentBuildings == 0 &&
                p.Status.Equals(PlayerStatus.Playing) &&
                p.SupplyMax == 0 &&
                p.SupplyMin == 0 &&
                p.Worker == 0 &&
                p.Minerals == 0 &&
                p.Gas == 0)
                return true;

            return false;
        }
Esempio n. 2
0
        private void GatherAndMapPlayerData()
        {
            if (!CAccessPlayers)
                return;

            _.Info("Fetching Player Data", _.InfoImportance.NotImportant);

            // Player Buffer
            var playerLenght = _maxPlayerAmount * MyOffsets.PlayerStructSize;
            var playerChunk = Memory.ReadMemory(MyOffsets.PlayerStruct, playerLenght);

            // Counts the valid race- holders (Ai, Human)
            var iRaceCounter = 0;
            var lPlayer = new List<Player>(_maxPlayerAmount);

            if (playerChunk.Length > 0)
            {
                for (var i = 0; i < _maxPlayerAmount; i++)
                {

                    var p = new Player();

                    p.CameraPositionX = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerCameraX + (i * MyOffsets.PlayerStructSize));
                    p.CameraPositionY = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerCameraY + (i * MyOffsets.PlayerStructSize));
                    p.CameraDistance = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerCameraDistance + (i * MyOffsets.PlayerStructSize));
                    p.CameraAngle = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerCameraAngle + (i * MyOffsets.PlayerStructSize));
                    p.CameraRotation = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerCameraRotation + (i * MyOffsets.PlayerStructSize));
                    p.Difficulty = (PlayerDifficulty)playerChunk[MyOffsets.RawPlayerDifficulty + (i * MyOffsets.PlayerStructSize)];
                    p.Status = GetGPlayerStatusModified(playerChunk[MyOffsets.RawPlayerStatus + (i * MyOffsets.PlayerStructSize)]);
                    p.Type = GetGPlayerTypeModified(playerChunk[MyOffsets.RawPlayerPlayertype + (i * MyOffsets.PlayerStructSize)]);
                    p.NameLength = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerNamelenght + (i * MyOffsets.PlayerStructSize)) >> 2;
                    p.Name = Encoding.UTF8.GetString(playerChunk, MyOffsets.RawPlayerName + (i * MyOffsets.PlayerStructSize), p.NameLength);
                    p.ClanTag = Encoding.UTF8.GetString(playerChunk, MyOffsets.RawPlayerClanTag + (i * MyOffsets.PlayerStructSize), 6);
                    p.Color = GetGPlayerColorModified(BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerColor + (i * MyOffsets.PlayerStructSize)));
                    p.Apm = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerApmCurrent + (i * MyOffsets.PlayerStructSize));
                    p.Epm = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerEpmCurrent + (i * MyOffsets.PlayerStructSize));
                    p.ApmAverage = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerApmAverage + (i * MyOffsets.PlayerStructSize));
                    p.EpmAverage = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerEpmAverage + (i * MyOffsets.PlayerStructSize));
                    p.Worker = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerWorkers + (i * MyOffsets.PlayerStructSize));
                    p.UnitsInProduction = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerUnitsInProduction + (i * MyOffsets.PlayerStructSize));
                    p.AccountId = Encoding.UTF8.GetString(playerChunk, MyOffsets.RawPlayerAccountId + (i * MyOffsets.PlayerStructSize), 16);
                    p.SupplyMaxRaw = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerSupplyMax + (i * MyOffsets.PlayerStructSize));
                    p.SupplyMinRaw = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerSupplyMin + (i * MyOffsets.PlayerStructSize));
                    p.SupplyMax = p.SupplyMaxRaw >> 12;
                    p.SupplyMin = p.SupplyMinRaw >> 12;
                    p.ArmySupply = p.SupplyMin - p.Worker;
                    p.CurrentBuildings = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerCurrentBuildings + (i * MyOffsets.PlayerStructSize));
                    p.Minerals = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerMinerals + (i * MyOffsets.PlayerStructSize));
                    p.Gas = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerGas + (i * MyOffsets.PlayerStructSize));
                    p.MineralsIncome = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerMineralsIncome + (i * MyOffsets.PlayerStructSize));
                    p.GasIncome = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerGasIncome + (i * MyOffsets.PlayerStructSize));
                    p.MineralsArmy = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerMineralsArmy + (i * MyOffsets.PlayerStructSize));
                    p.GasArmy = BitConverter.ToInt32(playerChunk, MyOffsets.RawPlayerGasArmy + (i * MyOffsets.PlayerStructSize));
                    p.Team = playerChunk[MyOffsets.RawPlayerTeam + (i * MyOffsets.PlayerStructSize)];
                    p.Index = i;

                    if ((p.Type == PlayerType.Human ||
                        p.Type == PlayerType.Ai) &&
                        _lRace.Count > iRaceCounter)
                    {
                        p.PlayerRace = _lRace[iRaceCounter];
                        iRaceCounter++;
                    }

                    //* We check if the Player (name) does exist. If it does not, we
                    // * reduce the actual Playersize and save time! */
                    //if (!p.Type.Equals(PredefinedTypes.PlayerType.Neutral))
                    //{
                    //    if (p.NameLength <= 0 ||
                    //        p.Name.StartsWith("\0"))
                    //    {
                    //        _maxPlayerAmount = i + 1;
                    //        continue;
                    //    }
                    //}

                    lPlayer.Add(p);
                }

                Player = lPlayer;

                var iLocalPlayer = GetGPlayerLocalplayer();
                if (iLocalPlayer < 16)
                    PredefinedTypes.Player.LocalPlayer = Player[iLocalPlayer];

                else
                    PredefinedTypes.Player.LocalPlayer = null;
            }

            else
            {
                if (Player.Count > 0)
                    Player.Clear();
            }
        }