Skip to content

Commit

Permalink
Fixes broken role owner ID splitting
Browse files Browse the repository at this point in the history
We were attempting to split role owner identifiers even when the
value was `null`. This checks for the existence of the value prior
to attempting the split.
  • Loading branch information
AugmenTab committed Jun 28, 2023
1 parent f7006bb commit 3df39cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Bug Fixes

* Fixes bug where weapon nickname references in the HTML templates were broken.
* Fixes bug where null value role owner references were having illegal operations performed on them.

## 0.3.0

Expand Down
8 changes: 6 additions & 2 deletions module/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ Handlebars.registerHelper("doMath", function(...var_args) {
*/
Handlebars.registerHelper("getEntity", function(type, id) {
switch(type) {
case "actor": return game.actors.get(id.split("_")[1]);
default: return null;
case "actor":
if (!id) return null;
return game.actors.get(id.split("_")[1]);

default:
return null;
}
});

Expand Down
2 changes: 2 additions & 0 deletions module/vehicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export function getPropulsion(propulsion) {
* @return {Actor|null} The current Actor assigned to the role, if applicable.
*/
export function getRoleOwner(assignment) {
if (!assignment) return null;

const actorId = assignment.split("_")[1];
const actor = game.actors.get(actorId);

Expand Down

1 comment on commit 3df39cd

@AugmenTab
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.