Skip to content

Commit 8be3e90

Browse files
authored
Merge pull request #24 from monkeyman192/update/157371.0
Update for NMS version 157371
2 parents f378e9d + 2d32f4f commit 8be3e90

File tree

10 files changed

+9456
-17701
lines changed

10 files changed

+9456
-17701
lines changed

nmspy/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def game_state(self) -> Optional[nms.cGcGameState]:
2424
@property
2525
def simulation(self) -> Optional[nms.cGcSimulation]:
2626
if self.GcApplication is not None:
27-
return self.GcApplication.mpData.contents.mSimulation
27+
if self.GcApplication.mpData:
28+
return self.GcApplication.mpData.contents.mSimulation
2829

2930
@property
3031
def player(self) -> Optional[nms.cGcPlayer]:

nmspy/data/basic_types.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,37 @@ def __hash__(self) -> int:
288288
return fnv_1a(str(self), self._size)
289289

290290

291+
class cTkFixedWString(ctypes.Structure):
292+
"""Equivalent of cTkFixedString<N,wchar_t>"""
293+
294+
_size: int
295+
value: bytes
296+
297+
def set(self, val: str):
298+
"""Set the value of the string."""
299+
new_len = len(val)
300+
self.value = val[: self._size].encode() + (self._size - new_len) * b"\x00"
301+
302+
def __class_getitem__(cls: type["cTkFixedWString"], key: int):
303+
_cls: type["cTkFixedWString"] = types.new_class(
304+
f"cTkFixedWString<0x{key:X}>", (cls,)
305+
)
306+
_cls._size = key
307+
_cls._fields_ = [("value", ctypes.c_wchar * key)]
308+
return _cls
309+
310+
def __str__(self) -> str:
311+
return self.value.decode()
312+
313+
def __eq__(self, other: str) -> bool:
314+
return str(self) == other
315+
316+
def __repr__(self) -> str:
317+
return str(self)
318+
319+
291320
class cTkFixedString(ctypes.Structure):
292-
"""Equivalent of MBINCompilers' NMSString0xXXX. Specify the size in bytes."""
321+
"""Equivalent of cTkFixedString<N,char_t>"""
293322

294323
_size: int
295324
value: bytes
@@ -601,5 +630,12 @@ def __str__(self):
601630
cTkFixedString0x200 = cTkFixedString[0x200]
602631
cTkFixedString0x400 = cTkFixedString[0x400]
603632
cTkFixedString0x800 = cTkFixedString[0x800]
633+
cTkFixedWString0x20 = cTkFixedWString[0x20]
634+
cTkFixedWString0x40 = cTkFixedWString[0x40]
635+
cTkFixedWString0x80 = cTkFixedWString[0x80]
636+
cTkFixedWString0x100 = cTkFixedWString[0x100]
637+
cTkFixedWString0x200 = cTkFixedWString[0x200]
638+
cTkFixedWString0x400 = cTkFixedWString[0x400]
639+
cTkFixedWString0x800 = cTkFixedWString[0x800]
604640
# Vector type aliases
605641
cTkBigPos = cTkPhysRelVec3

nmspy/data/enums/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
eStormState,
88
eLanguageRegion,
99
EnvironmentLocation,
10+
EPulseDriveState,
1011
)
1112

1213
# The following list is auto-generated.

nmspy/data/enums/internal_enums.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,11 @@ class Enum(IntEnum):
9797
InSpaceObject = 0xD
9898
Nexus = 0xE
9999
Anomaly = 0xF
100+
101+
102+
class EPulseDriveState(IntEnum):
103+
None_ = 0x0
104+
Charge = 0x1
105+
Jumping = 0x2
106+
CrashStop = 0x3
107+
Cooldown = 0x4

0 commit comments

Comments
 (0)