Beispiel #1
0
        private void CheckUberStates(LogicManager logic)
        {
            DateTime date = DateTime.Now;
            Dictionary <long, UberState> uberStates = logic.Memory.GetUberStates();

            foreach (KeyValuePair <long, UberState> pair in uberStates)
            {
                long      key   = pair.Key;
                UberState state = pair.Value;

                if (state.GroupName == "statsUberStateGroup" || (state.GroupName == "achievementsGroup" && state.Name == "spiritLightGainedCounter"))
                {
                    continue;
                }

                UberState oldState = null;
                if (currentUberStates.TryGetValue(key, out oldState))
                {
                    UberValue value    = state.Value;
                    UberValue oldValue = oldState.Value;
                    if (value.Int != oldValue.Int)
                    {
                        AddEntryUnlocked(new ValueLogEntry(date, LogObject.UberState, oldState.Clone(), state.Clone()));
                        oldState.Value = state.Value;
                    }
                }
                else
                {
                    currentUberStates[key] = state.Clone();
                }
            }
        }
 private void CheckBoolUberState(Split split)
 {
     try {
         var parts = split.Value.Split('|');
         if (int.TryParse(parts[0], out int groupId))
         {
             if (int.TryParse(parts[1], out int id))
             {
                 UberState value = Memory.GetUberState(groupId, id);
                 if (value != null)
                 {
                     CheckUberBoolValue(value);
                 }
             }
             else
             {
                 Log.Error($"failed to parse {split.Value}");
             }
         }
         else
         {
             Log.Error($"failed to parse {split.Value}");
         }
     } catch (Exception e) {
         Log.Error($"Exception thrown parsing {split.Value}: {e}");
     }
 }
 private void CheckUberIntValue(UberState value, int currentValue, int lastValue = int.MinValue)
 {
     Memory.UpdateUberState(value);
     if (lastValue == int.MinValue)
     {
         ShouldSplit = value.Value.Int == currentValue && lastIntValue != currentValue;
     }
     else
     {
         ShouldSplit = value.Value.Int == currentValue && lastIntValue == lastValue;
     }
     lastIntValue = value.Value.Int;
 }
        public void UpdateUberState(UberState uberState = null)
        {
            //UbserStateController.m_currentStateValueStore.m_groupMap
            IntPtr groups = UberStateController.Read <IntPtr>(Program, 0xb8, 0x40, 0x18);
            //.Count
            int groupCount = Program.Read <int>(groups, 0x20);

            //.Values
            groups = Program.Read <IntPtr>(groups, 0x18);
            byte[] groupsData = Program.Read(groups + 0x20, groupCount * 0x18);

            bool updateAll = uberState == null;

            for (int i = 0; i < groupCount; i++)
            {
                //.Values[i].m_id.m_id
                IntPtr group     = (IntPtr)BitConverter.ToUInt64(groupsData, 0x10 + (i * 0x18));
                byte[] groupData = Program.Read(group + 0x18, 48);
                long   groupID   = Program.Read <int>((IntPtr)BitConverter.ToUInt64(groupData, 0), 0x10);

                if (!updateAll && groupID != uberState.GroupID)
                {
                    continue;
                }

                //.Values[i].m_objectStateMap
                IntPtr map = (IntPtr)BitConverter.ToUInt64(groupData, 8);
                //.Values[i].m_objectStateMap.Count
                int mapCount = Program.Read <int>(map, 0x20);
                if (mapCount > 0 && (updateAll || uberState.IsObjectType))
                {
                    map = Program.Read <IntPtr>(map, 0x18);
                    byte[] data = Program.Read(map + 0x20, mapCount * 0x18);
                    for (int j = 0; j < mapCount; j++)
                    {
                        //.Values[i].m_objectStateMap.Keys[j]
                        long id = BitConverter.ToInt32(data, j * 0x18);

                        if (!updateAll && id != uberState.ID)
                        {
                            continue;
                        }

                        if (!updateAll || uberIDLookup.TryGetValue((groupID << 32) | id, out uberState))
                        {
                            if (uberState.Type == UberStateType.SavePedestalUberState)
                            {
                                uberState.Value.Byte = Program.Read <byte>((IntPtr)BitConverter.ToUInt64(data, 0x10 + (j * 0x18)), 0x11);
                            }
                            else
                            {
                                //playerUberStateDescriptor
                            }
                        }
                    }
                }

                //.Values[i].m_boolStateMap
                map = (IntPtr)BitConverter.ToUInt64(groupData, 16);
                //.Values[i].m_boolStateMap.Count
                mapCount = Program.Read <int>(map, 0x20);
                if (mapCount > 0 && (updateAll || uberState.IsBoolType))
                {
                    map = Program.Read <IntPtr>(map, 0x18);
                    byte[] data = Program.Read(map + 0x20, mapCount * 0x18);
                    for (int j = 0; j < mapCount; j++)
                    {
                        //.Values[i].m_boolStateMap.Keys[j]
                        long id = BitConverter.ToInt32(data, j * 0x18);

                        if (!updateAll && id != uberState.ID)
                        {
                            continue;
                        }

                        if (!updateAll || uberIDLookup.TryGetValue((groupID << 32) | id, out uberState))
                        {
                            uberState.Value.Bool = data[0x10 + (j * 0x18)] != 0;
                        }
                    }
                }

                //.Values[i].m_floatStateMap
                map = (IntPtr)BitConverter.ToUInt64(groupData, 24);
                //.Values[i].m_floatStateMap.Count
                mapCount = Program.Read <int>(map, 0x20);
                if (mapCount > 0 && (updateAll || uberState.IsFloatType))
                {
                    map = Program.Read <IntPtr>(map, 0x18);
                    byte[] data = Program.Read(map + 0x20, mapCount * 0x18);
                    for (int j = 0; j < mapCount; j++)
                    {
                        //.Values[i].m_floatStateMap.Keys[j]
                        long id = BitConverter.ToInt32(data, j * 0x18);

                        if (!updateAll && id != uberState.ID)
                        {
                            continue;
                        }

                        if (!updateAll || uberIDLookup.TryGetValue((groupID << 32) | id, out uberState))
                        {
                            uberState.Value.Float = BitConverter.ToSingle(data, 0x10 + (j * 0x18));
                        }
                    }
                }

                //.Values[i].m_intStateMap
                map = (IntPtr)BitConverter.ToUInt64(groupData, 32);
                //.Values[i].m_intStateMap.Count
                mapCount = Program.Read <int>(map, 0x20);
                if (mapCount > 0 && (updateAll || uberState.IsIntType))
                {
                    map = Program.Read <IntPtr>(map, 0x18);
                    byte[] data = Program.Read(map + 0x20, mapCount * 0x18);
                    for (int j = 0; j < mapCount; j++)
                    {
                        //.Values[i].m_intStateMap.Keys[j]
                        long id = BitConverter.ToInt32(data, j * 0x18);

                        if (!updateAll && id != uberState.ID)
                        {
                            continue;
                        }

                        if (!updateAll || uberIDLookup.TryGetValue((groupID << 32) | id, out uberState))
                        {
                            uberState.Value.Int = BitConverter.ToInt32(data, 0x10 + (j * 0x18));
                        }
                    }
                }

                //.Values[i].m_byteStateMap
                map = (IntPtr)BitConverter.ToUInt64(groupData, 40);
                //.Values[i].m_byteStateMap.Count
                mapCount = Program.Read <int>(map, 0x20);
                if (mapCount > 0 && (updateAll || uberState.IsByteType))
                {
                    map = Program.Read <IntPtr>(map, 0x18);
                    byte[] data = Program.Read(map + 0x20, mapCount * 0x18);
                    for (int j = 0; j < mapCount; j++)
                    {
                        //.Values[i].m_byteStateMap.Keys[j]
                        long id = BitConverter.ToInt32(data, j * 0x18);

                        if (!updateAll && id != uberState.ID)
                        {
                            continue;
                        }

                        if (!updateAll || uberIDLookup.TryGetValue((groupID << 32) | id, out uberState))
                        {
                            uberState.Value.Byte = data[0x10 + (j * 0x18)];
                        }
                    }
                }
            }
        }
        private void PopulateUberStates()
        {
            uberIDLookup = new Dictionary <long, UberState>();
            //UberStateCollection.Instance.m_descriptorsArray
            IntPtr descriptors = UberStateCollection.Read <IntPtr>(Program, 0xb8, 0x10, 0x20);
            //.Count
            int descriptorsCount = Program.Read <int>(descriptors, 0x18);

            byte[] data = Program.Read(descriptors + 0x20, descriptorsCount * 0x8);
            for (int i = 0; i < descriptorsCount; i++)
            {
                //.m_descriptorsArray[i]
                IntPtr descriptor = (IntPtr)BitConverter.ToUInt64(data, i * 0x8);

                UberStateType type = UberStateType.SerializedBooleanUberState;
                Enum.TryParse <UberStateType>(Program.ReadAscii(descriptor, 0x0, 0x10, 0x0), out type);

                int groupOffset = 0x38;
                switch (type)
                {
                case UberStateType.SerializedByteUberState:
                case UberStateType.SerializedIntUberState:
                case UberStateType.SavePedestalUberState: groupOffset = 0x30; break;

                case UberStateType.PlayerUberStateDescriptor: groupOffset = 0x40; break;

                case UberStateType.CountUberState:
                case UberStateType.BooleanUberState:
                case UberStateType.ByteUberState:
                case UberStateType.IntUberState:
                case UberStateType.ConditionUberState: continue;
                }

                //.m_descriptorsArray[i].ID.m_id
                int id = Program.Read <int>(descriptor, 0x18, 0x10);
                //.m_descriptorsArray[i].Name
                IntPtr namePtr = Program.Read <IntPtr>(descriptor, 0x10, 0x48);
                string name    = string.Empty;
                if (namePtr != IntPtr.Zero)
                {
                    name = Program.ReadAscii(namePtr);
                }
                else
                {
                    name = Program.ReadAscii(descriptor, 0x10, 0x50);
                }

                //.m_descriptorsArray[i].Group.ID.m_id
                int groupID = Program.Read <int>(descriptor, groupOffset, 0x18, 0x10);
                //.m_descriptorsArray[i].Group.Name
                namePtr = Program.Read <IntPtr>(descriptor, groupOffset, 0x10, 0x48);
                string groupName = string.Empty;
                if (namePtr != IntPtr.Zero)
                {
                    groupName = Program.ReadAscii(namePtr);
                }
                else
                {
                    groupName = Program.ReadAscii(descriptor, groupOffset, 0x10, 0x50);
                }
                UberState uberState = new UberState()
                {
                    Type = type, ID = id, Name = name, GroupID = groupID, GroupName = groupName
                };
                uberIDLookup.Add(((long)groupID << 32) | (long)id, uberState);
            }
        }
 private void CheckUberBoolValue(UberState value, bool currentValue = true)
 {
     Memory.UpdateUberState(value);
     ShouldSplit   = value.Value.Bool == currentValue && lastBoolValue != currentValue;
     lastBoolValue = value.Value.Bool;
 }