-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclasses_ro_structure.py
More file actions
51 lines (40 loc) · 1.6 KB
/
Copy pathclasses_ro_structure.py
File metadata and controls
51 lines (40 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
For accessing ragnarok's lists.
* This code looks ugly, I'm sorry. xD *
"""
class Node:
offset_to_next = 0x0
offset_to_prev = 0x4
offset_to_element = 0x8
def __init__(self, proc, addr, game_class):
self.proc = proc
self.addr = addr
self.addr_next = self.proc.read_int(self.addr + Node.offset_to_next)
self.addr_prev = self.proc.read_int(self.addr + Node.offset_to_prev)
self.addr_element = self.proc.read_int(self.addr + Node.offset_to_element)
self.game_class = game_class
def get_element(self):
return self.game_class(self.proc, self.addr_element)
class LinkedList:
offset_addr_begin = 0x0
offset_addr_end = 0x4
def __init__(self, proc, addr, game_class):
self.proc = proc
self.addr = addr
self.addr_begin = self.proc.read_int(self.addr + (LinkedList.offset_addr_begin))
self.addr_end = self.proc.read_int(self.addr + (LinkedList.offset_addr_end))
self.addr_current = self.addr_begin
self.at_end = False
self.game_class = game_class
self.current = Node(self.proc, self.addr_current, game_class)
def get_current(self):
return self.current.get_element()
def go_next(self):
if self.addr_current == self.addr_end:
self.at_end = True
if not self.at_end:
addr_next = self.current.addr_next
self.current = Node(self.proc, addr_next, self.game_class)
self.addr_current = addr_next
def has_next(self):
return not self.at_end