예제 #1
0
        private static void InitializeUnitFields(UpdateFieldValueCollection updateCollection, Dictionary <int, int> valuesDictionary, ref int valueIndex, EUnitFields_Vanilla endField = EUnitFields_Vanilla.PLAYER_END)
        {
            //subtract 1 from the length size because it's PlayerEnd
            for (int i = (int)EObjectFields.OBJECT_END; i < updateCollection.UpdateMask.Length && i < (int)endField; i++)
            {
                //TODO: Blacklist these fields
                //UNIT_FIELD_PERSUADED and UNIT_FIELD_PERSUADED +1
                //UNIT_CHANNEL_SPELL

                bool shouldWrite = VanillaToWotlkConverter.ConvertUpdateFieldsPlayer((EUnitFields_Vanilla)i, out int shiftAmount);

                //We need to track the index of nonwritten to wotlk, but written to the vanilla update block,
                //so that we may remove the byte chunk that represents the indicies
                if (updateCollection.UpdateMask[i])
                {
                    if (shouldWrite)
                    {
                        try
                        {
                            //We store in a dictionary with the value so that it may be written
                            //TODO: Store only index so we can do quick memcpy to new values array in the future for perf
                            valuesDictionary.Add(i + shiftAmount, updateCollection.UpdateDiffValues.Reinterpret <int>(valueIndex * sizeof(int)));
                        }
                        catch (Exception e)
                        {
                            throw new InvalidOperationException($"Failed to insert: i:{i}:{((EUnitFields_Vanilla)i).ToString()} [{i + shiftAmount}] [{((EUnitFields)(i + shiftAmount)).ToString()}] {updateCollection.UpdateDiffValues.Reinterpret<int>(valueIndex * sizeof(int))} into dictionary. \n\n Exception: {e.Message}", e);
                        }
                    }

                    //no matter what the value index should increase. Because
                    //otherwise it will get descyned from the new values
                    valueIndex++;
                }
            }
        }
예제 #2
0
        private static void InitializeContainerFields(UpdateFieldValueCollection updateCollection, Dictionary <int, int> valuesDictionary, ref int valueIndex)
        {
            for (int i = (int)EItemFields_Vanilla.ITEM_END; i < updateCollection.UpdateMask.Length && i < (int)EContainerFields_Vanilla.CONTAINER_END; i++)
            {
                bool shouldWrite = VanillaToWotlkConverter.ConvertUpdateFieldsContainer((EContainerFields_Vanilla)i, out int shiftAmount);

                //We need to track the index of nonwritten to wotlk, but written to the vanilla update block,
                //so that we may remove the byte chunk that represents the indicies
                if (updateCollection.UpdateMask[i])
                {
                    if (shouldWrite)
                    {
                        try
                        {
                            //We store in a dictionary with the value so that it may be written
                            //TODO: Store only index so we can do quick memcpy to new values array in the future for perf
                            valuesDictionary.Add(i + shiftAmount, updateCollection.UpdateDiffValues.Reinterpret <int>(valueIndex * sizeof(int)));
                        }
                        catch (Exception e)
                        {
                            throw new InvalidOperationException($"Failed to insert: i:{i}:{((EContainerFields_Vanilla)i).ToString()} [{i + shiftAmount}] [{((EContainerFields_Vanilla)(i + shiftAmount)).ToString()}] {updateCollection.UpdateDiffValues.Reinterpret<int>(valueIndex * sizeof(int))} into dictionary. \n\n Exception: {e.Message}", e);
                        }
                    }

                    //no matter what the value index should increase. Because
                    //otherwise it will get descyned from the new values
                    valueIndex++;
                }
            }
        }
예제 #3
0
        public static void Test_ConvertUpdateFieldGameObject_Converts_All_Values([Range((int)EObjectFields_Vanilla.OBJECT_END, (int)EGameObjectFields_Vanilla.OBJECT_END - 1)] int fieldNumber)
        {
            //arrange
            EGameObjectFields_Vanilla vanillaGameObjectField = (EGameObjectFields_Vanilla)fieldNumber;

            //act
            bool?result     = null;
            int  shiftValue = 0;

            Assert.DoesNotThrow(() => result = VanillaToWotlkConverter.ConvertUpdateFieldsGameObject(vanillaGameObjectField, out shiftValue), $"Field: {fieldNumber}:{vanillaGameObjectField}:{fieldNumber:X} is not converted.");
            int newFieldNumber = (shiftValue + fieldNumber);

            //Assert
            Assert.NotNull(result);
            Assert.True(newFieldNumber >= (int)EObjectFields_Vanilla.OBJECT_END && newFieldNumber <= (int)EGameObjectFields_Vanilla.OBJECT_END, $"Failed for {fieldNumber}:0x{fieldNumber:X}:{((EGameObjectFields_Vanilla)fieldNumber).ToString()}");
        }
예제 #4
0
        public static void Test_ConvertUpdateFieldContainer_Converts_All_Values([Range((int)EItemFields_Vanilla.ITEM_END, (int)EContainerFields_Vanilla.CONTAINER_END - 1)] int fieldNumber)
        {
            //arrange
            EContainerFields_Vanilla vanillaContainerField = (EContainerFields_Vanilla)fieldNumber;

            //act
            bool?result     = null;
            int  shiftValue = 0;

            Assert.DoesNotThrow(() => result = VanillaToWotlkConverter.ConvertUpdateFieldsContainer(vanillaContainerField, out shiftValue), $"Field: {fieldNumber}:{vanillaContainerField}:{fieldNumber:X} is not converted.");
            int newFieldNumber = (shiftValue + fieldNumber);

            //Assert
            Assert.NotNull(result);
            Assert.True(newFieldNumber >= (int)EItemFields.ITEM_END && newFieldNumber <= (int)EContainerFields.CONTAINER_END, $"Failed for {fieldNumber}:0x{fieldNumber:X}:{((EContainerFields_Vanilla)fieldNumber).ToString()}");
        }
예제 #5
0
        public static void Test_ConvertUpdateFieldItem_Converts_All_Values([Range((int)EObjectFields_Vanilla.OBJECT_END, (int)EItemFields_Vanilla.ITEM_END - 1)] int fieldNumber)
        {
            //arrange
            EItemFields_Vanilla vanillaItemField = (EItemFields_Vanilla)fieldNumber;

            //act
            bool?result     = null;
            int  shiftValue = 0;

            Assert.DoesNotThrow(() => result = VanillaToWotlkConverter.ConvertUpdateFieldsItem(vanillaItemField, out shiftValue), $"Field: {fieldNumber}:{vanillaItemField}:{fieldNumber:X} is not converted.");
            int newFieldNumber = (shiftValue + fieldNumber);

            //Assert
            Assert.NotNull(result);
            Assert.True(newFieldNumber >= (int)EObjectFields.OBJECT_END && newFieldNumber <= (int)EItemFields.ITEM_END);
        }