TIC-80 icon indicating copy to clipboard operation
TIC-80 copied to clipboard

load command behaves oddly around the website

Open MineRobber9000 opened this issue 6 months ago • 1 comments

The implementation of the website integration in TIC-80 creates the illusion of a folder structure; however, the load command behaves oddly around this boundary.

Steps to reproduce

  1. Create a folder called foo. (The name is irrelevant.)
  2. cd foo
  3. Save a cart called bar.tic (Again, name is irrelevant and only used for instructions.)
  4. cd ..
  5. load foo/bar.tic
  6. Observe how the file is loaded.
  7. Navigate into tic80.com and locate a cart. Remember the path of this cart.
  8. cd back to the root directory
  9. Attempt to load the cart using the path

Expected behavior The cart loads.

Actual behavior (as of 1.1.2837) The load errors with file not found or cart loading error.

MineRobber9000 avatar Jan 07 '24 14:01 MineRobber9000

The issue seems to be in the handling of the website. Specifically, the website only gets considered as a loadable target if we're inside the website's folder (if tic_fs_ispubdir returns true, which only happens if our working directory is in the website). Otherwise, it tries to load from the local filesystem, which naturally fails.

Even if we're inside the website directory and attempt to load a file from a directory, it still doesn't work, this time because tic_fs_enum only considers the working directory when trying to determine where a file exists (attempting to load, say, Play/Games/zracer.tic from the base tic80.com directory would only work if there was a file in the root path that had a filename of Play/Games/zracer.tic, which I was able to confirm via testing locally with my custom surf server).

The former issue could be solved by adding a check if we're in the root directory and loading a path which starts with TIC_HOST, and the latter issue could be solved using dirname and basename (or equivalents) to split the path into directory (which is appended to the working directory) and filename to search for.

MineRobber9000 avatar Jan 07 '24 15:01 MineRobber9000