Skip to content

Commit db03f90

Browse files
authored
Merge pull request #19 from monkeyman192/update/152998.0
Large update to include all types exposed by the game
2 parents 97d6233 + 3436bdc commit db03f90

File tree

14 files changed

+50234
-927
lines changed

14 files changed

+50234
-927
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ logs/
99
.venv/
1010
build/*
1111
*.egg-info/*
12+
13+
# Data generated by the extractor
14+
tools/struct_data.json

example_mods/audio_test_mod.py

Lines changed: 0 additions & 120 deletions
This file was deleted.

nmspy/data/basic_types.py

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def fnv_1a(input: str, length: int):
3131
return _hash
3232

3333

34+
# TODO: Rewrite a bit?
3435
class cTkBitArray(ctypes.Structure, Generic[T, N]):
3536
_size: int
3637
_template_type: T
@@ -208,6 +209,16 @@ class cTkPhysRelVec3(ctypes.Structure):
208209
]
209210

210211

212+
class GcResource(ctypes.Structure):
213+
ResourceID: int
214+
_fields_ = [("ResourceID", ctypes.c_int32)]
215+
216+
217+
class GcNodeID(ctypes.Structure):
218+
NodeID: int
219+
_fields_ = [("NodeID", ctypes.c_int32)]
220+
221+
211222
class GcSeed(ctypes.Structure):
212223
Seed: int
213224
UseSeedValue: bool
@@ -218,10 +229,12 @@ class GcSeed(ctypes.Structure):
218229
]
219230

220231

221-
cTkSeed = GcSeed
222-
223-
224232
class Colour(ctypes.Structure):
233+
r: float
234+
g: float
235+
b: float
236+
a: float
237+
225238
_fields_ = [
226239
("r", ctypes.c_float),
227240
("g", ctypes.c_float),
@@ -230,6 +243,20 @@ class Colour(ctypes.Structure):
230243
]
231244

232245

246+
class Colour32(ctypes.Structure):
247+
r: int
248+
g: int
249+
b: int
250+
a: int
251+
252+
_fields_ = [
253+
("r", ctypes.c_byte),
254+
("g", ctypes.c_byte),
255+
("b", ctypes.c_byte),
256+
("a", ctypes.c_byte),
257+
]
258+
259+
233260
class TkID(ctypes.Structure):
234261
"""TkID<128> -> TkID[0x10], TkID<256> -> TkID[0x20]"""
235262

@@ -387,7 +414,7 @@ def __class_getitem__(cls: Type["cTkClassPool"], key: tuple[Type[T], int]):
387414

388415

389416
class cTkDynamicArray(ctypes.Structure, Generic[T]):
390-
_template_type: T
417+
_template_type: Type[T]
391418
_fields_ = [
392419
("Array", ctypes.c_uint64),
393420
("Size", ctypes.c_uint32),
@@ -402,8 +429,8 @@ class cTkDynamicArray(ctypes.Structure, Generic[T]):
402429
@property
403430
def value(self) -> ctypes.Array[T]:
404431
if self.Array == 0 or self.Size == 0:
405-
# Empty lists are store with an empty pointer in mem.
406-
return []
432+
# Empty lists are stored with an empty pointer in mem.
433+
return (self._template_type * 0)()
407434
return map_struct(self.Array, self._template_type * self.Size)
408435

409436
def set(self, data: ctypes.Array[T]):
@@ -518,3 +545,51 @@ def __class_getitem__(
518545
("tableSize", ctypes.c_int32),
519546
]
520547
return _cls
548+
549+
550+
class halfVector4(ctypes.Structure):
551+
pass
552+
553+
554+
class HashedString(ctypes.Structure):
555+
pass
556+
557+
558+
class NMSTemplate(ctypes.Structure):
559+
pass
560+
561+
562+
class LinkableNMSTemplate(ctypes.Structure):
563+
pass
564+
565+
566+
class VariableSizeString(cTkDynamicArray[ctypes.c_char]):
567+
@property
568+
def value(self) -> str:
569+
return super().value.value.decode()
570+
571+
def __str__(self):
572+
return self.value
573+
574+
575+
class VariableSizeWString(cTkDynamicArray[ctypes.c_wchar]):
576+
@property
577+
def value(self) -> str:
578+
return super().value.value.decode()
579+
580+
def __str__(self):
581+
return self.value
582+
583+
584+
# Aliases
585+
cTkSeed = GcSeed
586+
# String type aliases
587+
TkID0x10 = TkID[0x10]
588+
TkID0x20 = TkID[0x20]
589+
cTkFixedString0x20 = cTkFixedString[0x20]
590+
cTkFixedString0x40 = cTkFixedString[0x40]
591+
cTkFixedString0x80 = cTkFixedString[0x80]
592+
cTkFixedString0x100 = cTkFixedString[0x100]
593+
cTkFixedString0x200 = cTkFixedString[0x200]
594+
cTkFixedString0x400 = cTkFixedString[0x400]
595+
cTkFixedString0x800 = cTkFixedString[0x800]

nmspy/data/enums/__init__.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
RespawnReason,
66
StateEnum,
77
eStormState,
8+
eLanguageRegion,
89
)
910

1011
# The following list is auto-generated.
@@ -21,8 +22,8 @@
2122
cGcInputActions,
2223
cTkTestBitFieldEnum,
2324
cTkInputHandEnum,
24-
cTkInputEnum,
2525
cTkInputAxisEnum,
26+
cTkInputEnum,
2627
cTkSketchConditions,
2728
cTkTrophyEnum,
2829
cTkCoordinateOrientation,
@@ -124,21 +125,21 @@
124125
cGcSentinelTypes,
125126
cGcDroneTypes,
126127
cGcProjectileImpactType,
127-
cGcPlayerSurvivalBarType,
128-
cGcScanType,
129128
cGcDamageType,
129+
cGcScanType,
130+
cGcPlayerCharacterStateType,
130131
cGcPlayerHazardType,
131-
cGcPhotoShip,
132+
cGcPlayerSurvivalBarType,
132133
cGcHand,
133134
cGcHandType,
134135
cGcMovementDirection,
135-
cGcPlayerCharacterStateType,
136136
cGcPhotoBuilding,
137137
cGcPhotoCreature,
138138
cGcPhotoPlant,
139-
cGcNPCSettlementBehaviourState,
139+
cGcPhotoShip,
140140
cGcNPCSettlementBehaviourAreaProperty,
141141
cGcNPCInteractiveObjectType,
142+
cGcNPCSettlementBehaviourState,
142143
cGcMissionCategory,
143144
cGcMissionConditionTest,
144145
cGcMissionDifficulty,
@@ -153,8 +154,8 @@
153154
cGcDay,
154155
cGcInteractionMissionState,
155156
cGcLocalSubstanceType,
156-
cGcDefaultMissionProductEnum,
157157
cGcDefaultMissionSubstanceEnum,
158+
cGcDefaultMissionProductEnum,
158159
cGcMissionConditionUsingPortal,
159160
cGcMissionConditionUsingThirdPersonCamera,
160161
cGcMissionConditionSentinelLevel,
@@ -192,11 +193,11 @@
192193
cGcBuildingDensityLevels,
193194
cGcBuildingSystemTypeEnum,
194195
cGcBuildingClassification,
195-
cGcNPCSeatedPosture,
196196
cGcPetAccessoryType,
197197
cGcNPCTriggerTypes,
198198
cGcCreatureSpawnEnum,
199199
cGcNPCPropType,
200+
cGcNPCSeatedPosture,
200201
cGcCreatureGroups,
201202
cGcCreatureHemiSphere,
202203
cGcCreatureRoles,
@@ -222,26 +223,26 @@
222223
cGcHologramState,
223224
cGcHologramType,
224225
cGcHologramPivotType,
225-
cGcCharacterControlInputValidity,
226226
cGcCharacterControlOutputSpace,
227227
cGcStatsTypes,
228228
cGcWordCategoryTableEnum,
229+
cGcCharacterControlInputValidity,
229230
cGcItemFilterMatchIDType,
230-
cGcUnlockableItemTreeGroups,
231231
cGcWeightingCurve,
232+
cGcUnlockableItemTreeGroups,
233+
cGcTradeCategory,
232234
cGcTechnologyCategory,
233235
cGcTechnologyRarity,
234-
cGcTradeCategory,
235-
cGcStatsEnum,
236-
cGcSettlementStatStrength,
237236
cGcSizeIndicator,
237+
cGcSettlementStatStrength,
238+
cGcStatsEnum,
238239
cGcRewardTeleport,
239240
cGcRewardStartShipBuildMode,
240241
cGcRewardSignalScan,
241242
cGcRewardScanEventOutcome,
242243
cGcRewardRepairWholeInventory,
243-
cGcRewardFrigateDamageResponse,
244244
cGcRewardJourneyThroughCentre,
245+
cGcRewardFrigateDamageResponse,
245246
cGcRewardEndSettlementExpedition,
246247
cGcRealitySubstanceCategory,
247248
cGcRewardAtlasPathProgress,
@@ -320,13 +321,13 @@
320321
cGcSettlementTowerPower,
321322
cGcPlayerMissionParticipantType,
322323
cGcGameMode,
323-
cGcFreighterNPCType,
324324
cGcNPCNavSubgraphNodeType,
325325
cGcPersistentBaseTypes,
326-
cGcBuildMenuOption,
326+
cGcFreighterNPCType,
327327
cGcLinkNetworkTypes,
328328
cGcNPCHabitationType,
329329
cGcBuildingPlacementErrorTypes,
330+
cGcBuildMenuOption,
330331
cGcBaseBuildingSecondaryMode,
331332
cGcBaseSnapState,
332333
cGcBaseBuildingPartStyle,

0 commit comments

Comments
 (0)