Esempio n. 1
0
        private void ExportSponsorId(SponsorContractDataEntity dataEntity, SponsorContractDataLocator dataLocator)
        {
            const int slotReferenceBaseAddress = 0x0120526C;
            const int teamBlockSize            = 0x00001E90;

            // Write slot value if a sponsor is assigned to the contract
            if (dataEntity.SponsorId != 0)
            {
                var teamMultiplier       = dataEntity.TeamId - 1;
                var slotReferenceAddress = slotReferenceBaseAddress + teamBlockSize * teamMultiplier; // Address of SponsorId 0 (none)
                var slotAddress          = slotReferenceAddress + dataEntity.SponsorId * 4;           // Export the SponsorId as an address value

                var slotInstructions = new List <byte>();

                slotInstructions.AddRange(new byte[] { 0xC7, 0x05 });                // mov
                slotInstructions.AddRange(BitConverter.GetBytes(slotAddress));       //         ds:dword_XXXXXX,
                slotInstructions.AddRange(BitConverter.GetBytes(dataEntity.SlotId)); //                          X

                _dataEndpoint.GameExecutableFileResource.WriteBytes(dataLocator.SlotInstruction, slotInstructions.ToArray());
            }
            else
            {
                var slotInstructions = new List <byte>();

                slotInstructions.AddRange(new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // nop

                _dataEndpoint.GameExecutableFileResource.WriteBytes(dataLocator.SlotInstruction, slotInstructions.ToArray());
            }
        }
Esempio n. 2
0
        private int ImportSponsorId(SponsorContractDataLocator dataLocator, int teamId, int slotId)
        {
            const int slotReferenceBaseAddress = 0x0120526C;
            const int teamBlockSize            = 0x00001E90;

            // Return if slot does not have a contract
            var instructionValue = _dataEndpoint.GameExecutableFileResource.ReadByte(dataLocator.SlotInstruction);

            if (instructionValue == 0x90)
            {
                return(0);
            }

            // Get the slot value in the slot record
            var slotValue = _dataEndpoint.GameExecutableFileResource.ReadInteger(dataLocator.SlotValue);

            // Throw exception if game data is not correctly ordered by slots
            if (slotValue != slotId)
            {
                throw new ArgumentOutOfRangeException(nameof(slotValue));
            }

            // Get the slot address in the slot record
            var slotAddress = _dataEndpoint.GameExecutableFileResource.ReadInteger(dataLocator.SlotAddress);

            // Calculate and return the sponsor id using the address where the slot value is recorded against
            var teamMultiplier       = teamId - 1;
            var slotReferenceAddress = slotReferenceBaseAddress + teamBlockSize * teamMultiplier; // Address of SponsorId 0 (none)

            return((slotAddress - slotReferenceAddress) / 4);
        }
Esempio n. 3
0
        private int ImportCashValue(SponsorContractDataLocator dataLocator)
        {
            // Return if slot does not have a contract
            var instructionValue = _dataEndpoint.GameExecutableFileResource.ReadByte(dataLocator.CashInstruction);

            if (instructionValue == 0x90)
            {
                return(0);
            }

            // Else return cash value
            return(_dataEndpoint.GameExecutableFileResource.ReadInteger(dataLocator.CashValue));
        }
Esempio n. 4
0
        private void ExportCashValue(SponsorContractDataEntity dataEntity, SponsorContractDataLocator dataLocator)
        {
            // Write cash value if a sponsor is assigned to the contract
            if (dataEntity.SponsorId != 0)
            {
                _dataEndpoint.GameExecutableFileResource.WriteInteger(dataLocator.CashValue, dataEntity.Cash);
            }
            else
            {
                var cashValueInstructions = new List <byte>();

                cashValueInstructions.AddRange(new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // nop

                _dataEndpoint.GameExecutableFileResource.WriteBytes(dataLocator.CashInstruction, cashValueInstructions.ToArray());
            }
        }