Co do BL lub PL to problem nie jest trywialny jak w poprzednich wersjach Tibii.
Nowy klient ma to do siebie, że jest napisany w QT i tam nie ma stringów tylko jest QString (taka ciekawostka). Co do clou problemu z BL to "cachuje" obiekty np. gracze czy NPCki, którzy zniknęli z ekranu (wtedy na BL jest przestawiane z 0 na 1 - visible / not visible). Natomiast co do np. id gracza na ekranie, nazwy, procentu życia czy pozycji x czy y to każdy offset wskazuje na inny pointer w innej lokalizacji pamięci. Przykładowo: encja gracza na BL o nicku Tomurka jest w adresie 0x1234, w adresie 0x1234+4 zawartość jest wartość pointera z hppc, który należy obliczyć (np. wartości 8C7), wtedy uzyskamy adres np. 0x1A43C: wartość 100. BL czy PL jest QT kolekcją - tak samo jak np. skille czy eq.
Co do wysyłania pakietów. Sprawa ma się podobnie jak w poprzednich wersjach Tibii - należy odnaleźć deltę XTEA i podpisywać nią pakiety (nie zmieniły się)
Pamiętaj, im krótsza droga w pointerze, tym szybciej będziesz odczytywać wartości.
Co do odczytywania to masz tutaj mały snippet mojego kodu, który odczytuje wartości z pamięci 🙂
Ogólnie cała magia wykonywana jest w ProcessMemoryLibrary oraz w pyTibiaMemory 😉
from typing import Union
from helpers.lib_process import ProcessMemoryLibrary
import pyTibiaMemory
class MemoryReader:
"""A class for reading data from a specified address in the memory of a particular process.
Parameters
----------
process_id : int
The ID of the process whose memory is to be read.
address : str
The address in the process's memory from which to start reading. The address should be
a string containing a hexadecimal number.
Attributes
----------
process_id: The ID of the process to read from.
address: The address in the process's memory from which to start reading, as an integer.
library: An object for interacting with library.
"""
def __init__(self, process_id: int, address: str) -> None:
self.process_id = process_id
self.address = int(address, 16)
self.library = ProcessMemoryLibrary(self.process_id)
def read(self, data_type: str) -> Union[int, float, bool, str]:
"""Read a value of the specified data type from the process's memory.
Parameters
----------
data_type : str
The data type of the value to be read. Supported data types are 'int', 'int16', 'int64',
'float', 'float64', 'byte', 'bool' and 'str'.
Returns
-------
int, float, bool or str
The value that was read. The return type depends on the specified data type.
Raises
------
ValueError
If an invalid data type is specified.
"""
case = {
'int': pyTibiaMemory.r_int,
'int16': pyTibiaMemory.r_int16,
'int64': pyTibiaMemory.r_int64,
'float': pyTibiaMemory.r_float,
'float64': pyTibiaMemory.r_float64,
'byte': pyTibiaMemory.r_byte,
'bool': pyTibiaMemory.r_bool,
'str': pyTibiaMemory.r_str,
}
read_case = case.get(data_type)
if read_case is None:
raise ValueError("Invalid data type")
return read_case(self.library.process, self.address)