Skip to content

Commit

Permalink
Add mitigations for H-uru#423.
Browse files Browse the repository at this point in the history
All `plCameraModifier` objects *must* have a brain or the client will
crash dereferencing a null pointer. This commit audits all
`plCameraModifier` creations and ensures that we are using a camera that
will have a brain. There are probably better ways to do this, but I am
le tired.
  • Loading branch information
Hoikas committed Dec 17, 2024
1 parent edf4e0e commit 9b7fbb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions korman/exporter/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def _export_camera_modifier(self, so, bo, props, trans):
continue
cam_trans = plCameraModifier.CamTrans()
if manual_trans.camera:
# Don't even bother if a disabled camera is referenced. If we export camera modifier
# for a disabled camera, then it won't get a brain, and the client will crash.
if not manual_trans.camera.plasma_object.enabled:
continue
cam_trans.transTo = self._mgr.find_create_key(plCameraModifier, bl=manual_trans.camera)
cam_trans.ignore = manual_trans.mode == "ignore"

Expand Down
2 changes: 2 additions & 0 deletions korman/exporter/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ def export_dynamic_env(self, bo, layer, texture, pl_class):
# least a SceneObject and CoordInterface so that we can touch it...
# NOTE: that harvest_actor makes sure everyone alread knows we're going to have a CI
if isinstance(viewpt.data, bpy.types.Camera):
if not viewpt.plasma_object.enabled:
raise ExportError(f"DynamicCamMap '{texture.name} wants to use the camera '{viewpt.name}', but it is not a Plasma Object!")
pl_env.camera = self._mgr.find_create_key(plCameraModifier, bl=viewpt)
else:
pl_env.rootNode = self._mgr.find_create_key(plSceneObject, bl=viewpt)
Expand Down

0 comments on commit 9b7fbb7

Please sign in to comment.