Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to the map name when the display name is equal or set empty #3861

Merged

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Mar 12, 2023

Identify the Bug or Feature request

Fixes #3857

Description of the Change

Now that player aliases can internally be null (e.g., when upgrading a campaign, or when the user sets the display name to the same as the regular name), a few macro functions started returning null or generating NPEs. These functions now fallback to the map name when a player alias is not set:

  • getMapDisplayName()
  • getMapName()
  • getAllMapDisplayNames()
  • getVisibleMapDisplayNames()
  • getInfo("map")

The loading banner will also now show the map name rather than 'null' if no player alias is set.

The new method Zone.getDisplayName() is used to consistently get the player-visible name of a map, whether that is the player alias or the map name.

Possible Drawbacks

Should be none

Documentation Notes

None (restores 1.12.2 behaviour)

Release Notes

N/A


This change is Reviewable

Calls to `MapFunctions.checkTrusted()` have been replaced with calls to the existing method
`FunctionUtil.blockUntrustedMacro()`. Calls to `MapFunctions.getNamedMap()` have been replaced with calls to the
existing method `FunctionUtil.getZoneRendererFromParam()`, or the new method `FunctionUtil.getZoneRenderer()` when the
name is required.

A new method `FunctionUtil.delimitedResult()` has been added for joining results into string lists or JSON arrays
depending on a user-provided value.
The behaviour of these function is back to their 1.12.2 behaviour, as they will no longer return `null` values for maps
that have no player alias set:
- `getMapDisplayName()`
- `getAllMapDisplayNames()`
- `getVisibleMapDisplayNames()`

Also `getMapName()` will once again be able to find maps by matching the name when no player alias is set.

The new method `Zone.getDisplayName()` can be used to get the name of the zone to show to players, whether that is the
player alias or the regular name.
@kwvanderlinde kwvanderlinde force-pushed the bugfix/3857-getMapDisplayName-npe branch from f310e58 to 715e9c2 Compare March 13, 2023 04:17
Copy link
Contributor

@Phergus Phergus left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @kwvanderlinde)

@Phergus Phergus merged commit fa0ee20 into RPTools:develop Mar 16, 2023
@kwvanderlinde kwvanderlinde deleted the bugfix/3857-getMapDisplayName-npe branch March 16, 2023 20:08
@cwisniew cwisniew added the bug label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

[Bug]: getMapDisplayName() returns error when map does not have a display name
3 participants