Skip to content

Commit

Permalink
Fix issue where script labels could may not match script behaviour wh…
Browse files Browse the repository at this point in the history
…en referring to deleted actors
  • Loading branch information
chrismaltby committed Dec 2, 2024
1 parent d56fd9b commit 8894b24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix UI palette text control code. Palette indices now go from 1 to 8, because zero byte is a string terminator [@untoxa](https://github.com/untoxa)
- Fix issue where migrating old projects could cause gbvm symbols to become empty, preventing build from completing (opening a broken project will now automatically fix this issue)
- Fix issue where sprites could end up with empty state id values
- Fix issue where script labels could may not match script behaviour when referring to deleted actors (dropdown would say Self, label would say Player, game would use Self)

## [4.1.3] - 2024-09-16

Expand Down
6 changes: 6 additions & 0 deletions src/components/script/hooks/useScriptEventTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ export const useScriptEventTitle = (
/ /g,
""
);
} else if (
actorsLookup[entityId] &&
sceneActorIds &&
sceneActorIds.indexOf(entityId) > -1
) {
return l10n("FIELD_SELF");
} else if (entityType === "actorPrefab") {
return l10n("FIELD_SELF");
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/compiler/scriptBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5553,16 +5553,20 @@ extern void __mute_mask_${symbol};
getActorIndex = (id: string): number => {
const { entity, entityType, scene } = this.options;

// Actor == player
if (id === "player" || (id === "$self$" && entityType !== "actor")) {
return 0;
}

// Actor == Self
if (id === "$self$" && entity) {
return getActorIndex(entity.id, scene);
}

// Find actor in current scene
const index = getActorIndex(id, scene);

// Actor id not found but entity was set, fall back to Self
if (entity && index === 0) {
return getActorIndex(entity.id, scene);
}
Expand Down

0 comments on commit 8894b24

Please sign in to comment.