trainerbase 3.1.4__tar.gz → 3.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trainerbase
3
- Version: 3.1.4
3
+ Version: 3.2.0
4
4
  Summary: Framework for creating game trainers/mods
5
5
  Home-page: https://gitlab.com/python-trainers/trainer-base
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "trainerbase"
3
- version = "3.1.4"
3
+ version = "3.2.0"
4
4
  description = "Framework for creating game trainers/mods"
5
5
  authors = ["v01d <v01d@v01d.ru>", "doomayka <zd@doomayka.ru>"]
6
6
  license = "MIT"
@@ -1,7 +1,7 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from collections.abc import Callable
3
3
  from functools import partial
4
- from typing import Self, assert_never
4
+ from typing import Self, assert_never, override
5
5
 
6
6
  from pymem import Pymem
7
7
  from pymem.exception import ProcessNotFound
@@ -55,6 +55,11 @@ class AOBScan(AbstractAddress):
55
55
  self.module_name = module_name
56
56
  self.multiple_result_index = multiple_result_index
57
57
 
58
+ def __add__(self, extra_add: int) -> Self:
59
+ new_add = self.add + extra_add
60
+ return self.inherit(new_add=new_add)
61
+
62
+ @override
58
63
  def resolve(self) -> int:
59
64
  if self._saved_scan_result is not None:
60
65
  return self._saved_scan_result
@@ -88,6 +93,20 @@ class AOBScan(AbstractAddress):
88
93
 
89
94
  return result_address
90
95
 
96
+ def inherit(self, *, new_add: int | None = None) -> Self:
97
+ new_address = self.__class__(
98
+ self.aob,
99
+ add=self.add,
100
+ module_name=self.module_name,
101
+ multiple_result_index=self.multiple_result_index,
102
+ should_cache=self._should_cache,
103
+ )
104
+
105
+ if new_add is not None:
106
+ new_address.add = new_add
107
+
108
+ return new_address
109
+
91
110
 
92
111
  class Address(AbstractAddress):
93
112
  def __init__(self, base_address: int, offsets: list[int] | None = None, add: int = 0):
@@ -105,8 +124,16 @@ class Address(AbstractAddress):
105
124
  case _:
106
125
  assert_never(other)
107
126
 
127
+ @override
128
+ def resolve(self) -> int:
129
+ pointer = self.base_address
130
+ for offset in self.offsets:
131
+ pointer = read_pointer(pointer) + offset
132
+
133
+ return pointer + self.add
134
+
108
135
  def inherit(self, *, extra_offsets: list[int] | None = None, new_add: int | None = None) -> Self:
109
- new_address = Address(self.base_address, self.offsets.copy(), self.add)
136
+ new_address = self.__class__(self.base_address, self.offsets.copy(), self.add)
110
137
 
111
138
  if extra_offsets is not None:
112
139
  new_address.offsets.extend(extra_offsets)
@@ -116,13 +143,6 @@ class Address(AbstractAddress):
116
143
 
117
144
  return new_address
118
145
 
119
- def resolve(self) -> int:
120
- pointer = self.base_address
121
- for offset in self.offsets:
122
- pointer = read_pointer(pointer) + offset
123
-
124
- return pointer + self.add
125
-
126
146
 
127
147
  def ensure_address(obj: ConvertibleToAddress) -> AbstractAddress:
128
148
  match obj:
File without changes
File without changes