Pathoschild / SMAPI

The modding API for Stardew Valley.
https://smapi.io/
GNU Lesser General Public License v3.0
1.87k stars 263 forks source link

Review rules for resolving map tilesheet #368

Closed Pathoschild closed 7 years ago

Pathoschild commented 7 years ago

A modder reported the following error:

image

Review the rules SMAPI uses to resolve map tilesheets.

Pathoschild commented 7 years ago

Game logic

The game's logic for finding tilesheets boils down to this:

  1. If the location is indoors or the desert, or the tilesheet path contains path or object, it's loaded as-is relative to the Content folder.
  2. Else it's loaded from Content\Maps with a seasonal prefix (e.g. spring_outdoorsTileSheet).

Most game maps reference a simple file name (like townInterior). Only the mines have a folder path (e.g. Mines\mine).

We can't use this logic in SMAPI because we don't have location info at that point, and modders often have more complex tilesheet paths.

Current SMAPI logic

SMAPI checks for an existing relative path match (with and without seasonal prefix) relative to three locations (map file, Content\Maps, and Content).

That works for most maps, but fails with workstation-specific paths like ..\..\Steam\Stardew Valley\Content\townInterior.png.

Option A: restrict tilesheet paths

Keep the logic as-is, and require modders to copy tilesheets into the same folder when editing the map. Detect paths containing ..\, and show an error saying tilesheets should in or under the map folder.

This keeps the SMAPI logic simple and predictable and avoids path ambiguity, but modders need to copy vanilla tilesheets into the map folder to reference it.

Option B: add filename matching

Check four variations (relative path and filename with/without seasonal prefix) relative to three locations (map file, Content\Maps, and Content). If the path contains ..\, disable relative path searches.

Advantages:

Disadvantages:

Pathoschild commented 7 years ago

We'll go with option A per discussion.

The recommended map editor is Tiled, which correctly uses a relative path if the tilesheet is under the map's folder (otherwise it uses an absolute path). SMAPI should detect if the path is rooted or contains ..\, and show an appropriate error.

Pathoschild commented 7 years ago

Done in develop for the upcoming SMAPI 2.0 release.