Skip to content

Commit

Permalink
#378 - achievements
Browse files Browse the repository at this point in the history
  • Loading branch information
HENDRIX-ZT2 committed Apr 27, 2024
1 parent 5fd6107 commit 280ea0e
Show file tree
Hide file tree
Showing 20 changed files with 764 additions and 11 deletions.
10 changes: 5 additions & 5 deletions generated/base_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ def _to_xml(cls, instance, elem, debug):
for f_name, f_type, arguments, (optional, default) in cls._get_filtered_attribute_list(instance):
if f_name in SKIPS:
continue
if cls.is_array_count(f_name, set_fields):
continue
field_value = getattr(instance, f_name)
# keep clean XML
if f_name.startswith(DO_NOT_SERIALIZE) or (optional and field_value == default):
if not debug:
if not debug:
if cls.is_array_count(f_name, set_fields):
continue
# keep clean XML
if f_name.startswith(DO_NOT_SERIALIZE) or (optional and field_value == default):
continue
# even valid fields may be set to None in some edge cases
if field_value is not None:
Expand Down
1 change: 1 addition & 0 deletions generated/formats/achievements/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from generated.formats.achievements.imports import name_type_map
83 changes: 83 additions & 0 deletions generated/formats/achievements/achievements.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE niftoolsxml>
<niftoolsxml version="0.7.1.0">

<xi:include href="../ovl_base/ovl_base.xml" xmlns:xi="http://www.w3.org/2001/XInclude" xpointer="xpointer(*/*)" />

<compound name="AchievementsRoot" inherit="MemStruct">
PZ: 48 bytes
<add name="condition_vars" type="ArrayPointer" template="ConditionVarPtr" arg="condition_vars_count"/>
<add name="condition_vars_count" type="uint64" />
<add name="condition_checks" type="ArrayPointer" template="ConditionCheck" arg="condition_checks_count"/>
<add name="condition_checks_count" type="uint64" />
<add name="c" type="ArrayPointer" template="Achievement" arg="c_count"/>
<add name="c_count" type="uint64" />
</compound>

<compound name="ConditionVarPtr" inherit="MemStruct">
<add name="condition_var" type="Pointer" template="ConditionVar"/>
</compound>

<compound name="ConditionRef" inherit="MemStruct">
<add name="mode" type="uint64" />
<add name="condition_var" type="Pointer" template="ConditionVar"/>reference to entries from condition_vars array
</compound>

<compound name="ConditionRef2" inherit="MemStruct">
PZ 64, or probably 48 bytes
<add name="ref_name" type="Pointer" template="ZString"/>
<add name="mode" type="uint64" />
<add name="condition_ref" type="Pointer" template="ConditionRef"/>
<add name="count" type="uint64" default="1"/>
<add name="zero1" type="uint64" default="0" optional="true" />
<add name="zero2" type="uint64" default="0" optional="true" />
<!-- <add name="zero3" type="uint64" default="0" optional="true" />-->
<!-- <add name="zero4" type="uint64" default="0" optional="true" />-->
</compound>

<compound name="ConditionRefPtr" inherit="MemStruct">
<add name="ptr" type="Pointer" template="ConditionRef"/>
</compound>

<compound name="ConditionRef2Ptr" inherit="MemStruct">
<add name="ptr" type="Pointer" template="ConditionRef2"/>
</compound>

<compound name="ConditionsPtr" inherit="MemStruct">
<add name="ptr" type="ArrayPointer" template="ConditionPtr" arg="count"/>
<add name="count" type="uint64" />
</compound>

<compound name="ConditionVar" inherit="MemStruct">
PZ 32 bytes
<add name="Condition_name" type="Pointer" template="ZString"/>
<add name="b" type="uint64" />
<add name="count" type="uint64" />
<add name="d" type="uint64" />
</compound>

<compound name="ConditionCheck" inherit="MemStruct">
PZ 40 bytes
<add name="Condition_name" type="Pointer" template="ZString"/>
<add name="Conditions2" type="ArrayPointer" template="ConditionRef2Ptr" arg="Conditions2_count"/>points to array of pointers
<add name="Conditions2_count" type="uint64" />
<add name="Conditions" type="ArrayPointer" template="ConditionRefPtr" arg="Conditions_count"/>
<add name="Conditions_count" type="uint64" />
</compound>

<compound name="Achievement" inherit="MemStruct">
PZ 64 bytes
<add name="achievement_name" type="Pointer" template="ZString"/>
<add name="Conditions" type="ArrayPointer" template="ConditionRefPtr" arg="Conditions_count"/>
<add name="Conditions_count" type="int" default="1" optional="true"/>
<add name="minus_one1" type="int" default="-1" optional="true" />
<add name="minus_one2" type="int" default="-1" optional="true" />
<add name="zero1" type="int" default="0" optional="true"/>
<add name="zero2" type="uint64" default="0" optional="true" />
<add name="flags" type="ubyte" arr1="4" />
<add name="zero3" type="int" default="0" optional="true" />
<add name="zero4" type="uint64" default="0" optional="true" />
<add name="zero5" type="uint64" default="0" optional="true" />
</compound>

</niftoolsxml>
59 changes: 59 additions & 0 deletions generated/formats/achievements/compounds/Achievement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from generated.array import Array
from generated.formats.achievements.imports import name_type_map
from generated.formats.ovl_base.compounds.MemStruct import MemStruct


class Achievement(MemStruct):

"""
PZ 64 bytes
"""

__name__ = 'Achievement'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.conditions_count = name_type_map['Int'].from_value(1)
self.minus_one_1 = name_type_map['Int'].from_value(-1)
self.minus_one_2 = name_type_map['Int'].from_value(-1)
self.zero_1 = name_type_map['Int'].from_value(0)
self.zero_2 = name_type_map['Uint64'].from_value(0)
self.flags = Array(self.context, 0, None, (0,), name_type_map['Ubyte'])
self.zero_3 = name_type_map['Int'].from_value(0)
self.zero_4 = name_type_map['Uint64'].from_value(0)
self.zero_5 = name_type_map['Uint64'].from_value(0)
self.achievement_name = name_type_map['Pointer'](self.context, 0, name_type_map['ZString'])
self.conditions = name_type_map['ArrayPointer'](self.context, self.conditions_count, name_type_map['ConditionRefPtr'])
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'achievement_name', name_type_map['Pointer'], (0, name_type_map['ZString']), (False, None), (None, None)
yield 'conditions', name_type_map['ArrayPointer'], (None, name_type_map['ConditionRefPtr']), (False, None), (None, None)
yield 'conditions_count', name_type_map['Int'], (0, None), (True, 1), (None, None)
yield 'minus_one_1', name_type_map['Int'], (0, None), (True, -1), (None, None)
yield 'minus_one_2', name_type_map['Int'], (0, None), (True, -1), (None, None)
yield 'zero_1', name_type_map['Int'], (0, None), (True, 0), (None, None)
yield 'zero_2', name_type_map['Uint64'], (0, None), (True, 0), (None, None)
yield 'flags', Array, (0, None, (4,), name_type_map['Ubyte']), (False, None), (None, None)
yield 'zero_3', name_type_map['Int'], (0, None), (True, 0), (None, None)
yield 'zero_4', name_type_map['Uint64'], (0, None), (True, 0), (None, None)
yield 'zero_5', name_type_map['Uint64'], (0, None), (True, 0), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'achievement_name', name_type_map['Pointer'], (0, name_type_map['ZString']), (False, None)
yield 'conditions', name_type_map['ArrayPointer'], (instance.conditions_count, name_type_map['ConditionRefPtr']), (False, None)
yield 'conditions_count', name_type_map['Int'], (0, None), (True, 1)
yield 'minus_one_1', name_type_map['Int'], (0, None), (True, -1)
yield 'minus_one_2', name_type_map['Int'], (0, None), (True, -1)
yield 'zero_1', name_type_map['Int'], (0, None), (True, 0)
yield 'zero_2', name_type_map['Uint64'], (0, None), (True, 0)
yield 'flags', Array, (0, None, (4,), name_type_map['Ubyte']), (False, None)
yield 'zero_3', name_type_map['Int'], (0, None), (True, 0)
yield 'zero_4', name_type_map['Uint64'], (0, None), (True, 0)
yield 'zero_5', name_type_map['Uint64'], (0, None), (True, 0)
43 changes: 43 additions & 0 deletions generated/formats/achievements/compounds/AchievementsRoot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from generated.formats.achievements.imports import name_type_map
from generated.formats.ovl_base.compounds.MemStruct import MemStruct


class AchievementsRoot(MemStruct):

"""
PZ: 48 bytes
"""

__name__ = 'AchievementsRoot'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.condition_vars_count = name_type_map['Uint64'](self.context, 0, None)
self.condition_checks_count = name_type_map['Uint64'](self.context, 0, None)
self.c_count = name_type_map['Uint64'](self.context, 0, None)
self.condition_vars = name_type_map['ArrayPointer'](self.context, self.condition_vars_count, name_type_map['ConditionVarPtr'])
self.condition_checks = name_type_map['ArrayPointer'](self.context, self.condition_checks_count, name_type_map['ConditionCheck'])
self.c = name_type_map['ArrayPointer'](self.context, self.c_count, name_type_map['Achievement'])
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'condition_vars', name_type_map['ArrayPointer'], (None, name_type_map['ConditionVarPtr']), (False, None), (None, None)
yield 'condition_vars_count', name_type_map['Uint64'], (0, None), (False, None), (None, None)
yield 'condition_checks', name_type_map['ArrayPointer'], (None, name_type_map['ConditionCheck']), (False, None), (None, None)
yield 'condition_checks_count', name_type_map['Uint64'], (0, None), (False, None), (None, None)
yield 'c', name_type_map['ArrayPointer'], (None, name_type_map['Achievement']), (False, None), (None, None)
yield 'c_count', name_type_map['Uint64'], (0, None), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'condition_vars', name_type_map['ArrayPointer'], (instance.condition_vars_count, name_type_map['ConditionVarPtr']), (False, None)
yield 'condition_vars_count', name_type_map['Uint64'], (0, None), (False, None)
yield 'condition_checks', name_type_map['ArrayPointer'], (instance.condition_checks_count, name_type_map['ConditionCheck']), (False, None)
yield 'condition_checks_count', name_type_map['Uint64'], (0, None), (False, None)
yield 'c', name_type_map['ArrayPointer'], (instance.c_count, name_type_map['Achievement']), (False, None)
yield 'c_count', name_type_map['Uint64'], (0, None), (False, None)
40 changes: 40 additions & 0 deletions generated/formats/achievements/compounds/ConditionCheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from generated.formats.achievements.imports import name_type_map
from generated.formats.ovl_base.compounds.MemStruct import MemStruct


class ConditionCheck(MemStruct):

"""
PZ 40 bytes
"""

__name__ = 'ConditionCheck'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.conditions_2_count = name_type_map['Uint64'](self.context, 0, None)
self.conditions_count = name_type_map['Uint64'](self.context, 0, None)
self.condition_name = name_type_map['Pointer'](self.context, 0, name_type_map['ZString'])
self.conditions_2 = name_type_map['ArrayPointer'](self.context, self.conditions_2_count, name_type_map['ConditionRef2Ptr'])
self.conditions = name_type_map['ArrayPointer'](self.context, self.conditions_count, name_type_map['ConditionRefPtr'])
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'condition_name', name_type_map['Pointer'], (0, name_type_map['ZString']), (False, None), (None, None)
yield 'conditions_2', name_type_map['ArrayPointer'], (None, name_type_map['ConditionRef2Ptr']), (False, None), (None, None)
yield 'conditions_2_count', name_type_map['Uint64'], (0, None), (False, None), (None, None)
yield 'conditions', name_type_map['ArrayPointer'], (None, name_type_map['ConditionRefPtr']), (False, None), (None, None)
yield 'conditions_count', name_type_map['Uint64'], (0, None), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'condition_name', name_type_map['Pointer'], (0, name_type_map['ZString']), (False, None)
yield 'conditions_2', name_type_map['ArrayPointer'], (instance.conditions_2_count, name_type_map['ConditionRef2Ptr']), (False, None)
yield 'conditions_2_count', name_type_map['Uint64'], (0, None), (False, None)
yield 'conditions', name_type_map['ArrayPointer'], (instance.conditions_count, name_type_map['ConditionRefPtr']), (False, None)
yield 'conditions_count', name_type_map['Uint64'], (0, None), (False, None)
27 changes: 27 additions & 0 deletions generated/formats/achievements/compounds/ConditionRef.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from generated.formats.achievements.imports import name_type_map
from generated.formats.ovl_base.compounds.MemStruct import MemStruct


class ConditionRef(MemStruct):

__name__ = 'ConditionRef'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.mode = name_type_map['Uint64'](self.context, 0, None)
self.condition_var = name_type_map['Pointer'](self.context, 0, name_type_map['ConditionVar'])
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'mode', name_type_map['Uint64'], (0, None), (False, None), (None, None)
yield 'condition_var', name_type_map['Pointer'], (0, name_type_map['ConditionVar']), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'mode', name_type_map['Uint64'], (0, None), (False, None)
yield 'condition_var', name_type_map['Pointer'], (0, name_type_map['ConditionVar']), (False, None)
43 changes: 43 additions & 0 deletions generated/formats/achievements/compounds/ConditionRef2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from generated.formats.achievements.imports import name_type_map
from generated.formats.ovl_base.compounds.MemStruct import MemStruct


class ConditionRef2(MemStruct):

"""
PZ 64, or probably 48 bytes
"""

__name__ = 'ConditionRef2'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.mode = name_type_map['Uint64'](self.context, 0, None)
self.count = name_type_map['Uint64'].from_value(1)
self.zero_1 = name_type_map['Uint64'].from_value(0)
self.zero_2 = name_type_map['Uint64'].from_value(0)
self.ref_name = name_type_map['Pointer'](self.context, 0, name_type_map['ZString'])
self.condition_ref = name_type_map['Pointer'](self.context, 0, name_type_map['ConditionRef'])
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'ref_name', name_type_map['Pointer'], (0, name_type_map['ZString']), (False, None), (None, None)
yield 'mode', name_type_map['Uint64'], (0, None), (False, None), (None, None)
yield 'condition_ref', name_type_map['Pointer'], (0, name_type_map['ConditionRef']), (False, None), (None, None)
yield 'count', name_type_map['Uint64'], (0, None), (False, 1), (None, None)
yield 'zero_1', name_type_map['Uint64'], (0, None), (True, 0), (None, None)
yield 'zero_2', name_type_map['Uint64'], (0, None), (True, 0), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'ref_name', name_type_map['Pointer'], (0, name_type_map['ZString']), (False, None)
yield 'mode', name_type_map['Uint64'], (0, None), (False, None)
yield 'condition_ref', name_type_map['Pointer'], (0, name_type_map['ConditionRef']), (False, None)
yield 'count', name_type_map['Uint64'], (0, None), (False, 1)
yield 'zero_1', name_type_map['Uint64'], (0, None), (True, 0)
yield 'zero_2', name_type_map['Uint64'], (0, None), (True, 0)
24 changes: 24 additions & 0 deletions generated/formats/achievements/compounds/ConditionRef2Ptr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from generated.formats.achievements.imports import name_type_map
from generated.formats.ovl_base.compounds.MemStruct import MemStruct


class ConditionRef2Ptr(MemStruct):

__name__ = 'ConditionRef2Ptr'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.ptr = name_type_map['Pointer'](self.context, 0, name_type_map['ConditionRef2'])
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'ptr', name_type_map['Pointer'], (0, name_type_map['ConditionRef2']), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'ptr', name_type_map['Pointer'], (0, name_type_map['ConditionRef2']), (False, None)
24 changes: 24 additions & 0 deletions generated/formats/achievements/compounds/ConditionRefPtr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from generated.formats.achievements.imports import name_type_map
from generated.formats.ovl_base.compounds.MemStruct import MemStruct


class ConditionRefPtr(MemStruct):

__name__ = 'ConditionRefPtr'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.ptr = name_type_map['Pointer'](self.context, 0, name_type_map['ConditionRef'])
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'ptr', name_type_map['Pointer'], (0, name_type_map['ConditionRef']), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'ptr', name_type_map['Pointer'], (0, name_type_map['ConditionRef']), (False, None)
Loading

0 comments on commit 280ea0e

Please sign in to comment.