Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nmspy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def game_state(self) -> Optional[nms.cGcGameState]:
@property
def simulation(self) -> Optional[nms.cGcSimulation]:
if self.GcApplication is not None:
return self.GcApplication.mpData.contents.mSimulation
if self.GcApplication.mpData:
return self.GcApplication.mpData.contents.mSimulation

@property
def player(self) -> Optional[nms.cGcPlayer]:
Expand Down
38 changes: 37 additions & 1 deletion nmspy/data/basic_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,37 @@ def __hash__(self) -> int:
return fnv_1a(str(self), self._size)


class cTkFixedWString(ctypes.Structure):
"""Equivalent of cTkFixedString<N,wchar_t>"""

_size: int
value: bytes

def set(self, val: str):
"""Set the value of the string."""
new_len = len(val)
self.value = val[: self._size].encode() + (self._size - new_len) * b"\x00"

def __class_getitem__(cls: type["cTkFixedWString"], key: int):
_cls: type["cTkFixedWString"] = types.new_class(
f"cTkFixedWString<0x{key:X}>", (cls,)
)
_cls._size = key
_cls._fields_ = [("value", ctypes.c_wchar * key)]
return _cls

def __str__(self) -> str:
return self.value.decode()

def __eq__(self, other: str) -> bool:
return str(self) == other

def __repr__(self) -> str:
return str(self)


class cTkFixedString(ctypes.Structure):
"""Equivalent of MBINCompilers' NMSString0xXXX. Specify the size in bytes."""
"""Equivalent of cTkFixedString<N,char_t>"""

_size: int
value: bytes
Expand Down Expand Up @@ -601,5 +630,12 @@ def __str__(self):
cTkFixedString0x200 = cTkFixedString[0x200]
cTkFixedString0x400 = cTkFixedString[0x400]
cTkFixedString0x800 = cTkFixedString[0x800]
cTkFixedWString0x20 = cTkFixedWString[0x20]
cTkFixedWString0x40 = cTkFixedWString[0x40]
cTkFixedWString0x80 = cTkFixedWString[0x80]
cTkFixedWString0x100 = cTkFixedWString[0x100]
cTkFixedWString0x200 = cTkFixedWString[0x200]
cTkFixedWString0x400 = cTkFixedWString[0x400]
cTkFixedWString0x800 = cTkFixedWString[0x800]
# Vector type aliases
cTkBigPos = cTkPhysRelVec3
1 change: 1 addition & 0 deletions nmspy/data/enums/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
eStormState,
eLanguageRegion,
EnvironmentLocation,
EPulseDriveState,
)

# The following list is auto-generated.
Expand Down
8 changes: 8 additions & 0 deletions nmspy/data/enums/internal_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,11 @@ class Enum(IntEnum):
InSpaceObject = 0xD
Nexus = 0xE
Anomaly = 0xF


class EPulseDriveState(IntEnum):
None_ = 0x0
Charge = 0x1
Jumping = 0x2
CrashStop = 0x3
Cooldown = 0x4
Loading