Skip to content

Various compatibility fixes for Upstate Liberty#130

Open
CookiePLMonster wants to merge 5 commits intothelink2012:developfrom
CookiePLMonster:upstate-fixes
Open

Various compatibility fixes for Upstate Liberty#130
CookiePLMonster wants to merge 5 commits intothelink2012:developfrom
CookiePLMonster:upstate-fixes

Conversation

@CookiePLMonster
Copy link
Copy Markdown
Contributor

This PR fixes a set of bugs and missing features in Modloader that prevented Upstate Liberty for GTA III from loading correctly.

  1. Arbitrarily named script files can now be loaded. This makes main_d.scm placed in a Modloader directory loadable through gtadebug.
  2. ASI files installed in scripts, plugins and mss now translate paths relatively to their parent path. The reasoning is that the path above any of the three is most likely the "mod root directory", and so the assumption is that files should load relatively to those. This fixes a case where the following mod structure worked standalone, but failed with Modloader:
    mod_dir\
       scripts\
          MyPlugin.asi <--- loads "data\myFile.dat"
       data\
          myFile.dat
    
  3. Path translations now always use an absolute path to the Modloader directory. This has multiple benefits:
    1. Path translation function is simplified greatly.
    2. CLEO script special-case has been removed, as there is no need to go "up" one directory anymore.
    3. Files loaded by the game through a chdir("data") (or similar) now work correctly. In the current version of Modloader, that current directory was correctly reconstructed inside the mod directory, but the actual chdir was not countered, so the game tried to load files from paths like:
      gta3\data\modloader\mod_dir\data\file.dat
      By using absolute paths, Modloader doesn't need to care about this chdir at all, and there is no need to try and traverse the directory back.
  4. Support for overriding MAPZONE definitions (map.zon file) has been added. This III-exclusive DAT definition has an identical syntax to IPL, so the IPL overrider was extended to also support this.
  5. An exit crash on freeing Profiles was fixed. I suspect it never crashed with older VS compilers, but with the one I used now, an attempt to iterate this->profiles in the middle of a this->profiles.clear() call consistently crashed. I untangled the code so the destructors of Profile don't touch this container at all, and instead it's the container's responsibility to unregister everything up front.

This set of fixes makes Upstate Liberty fully loadable from Modloader - just extract the mod archive to modloader\ and go.
image
image

Fixes #123. Fixes #127.

Fixes loading gtadebug through modloader,
main_d.scm and main_freeroam.scm are now loadable
…ed in scripts

When the ASI is in 'scripts', 'plugins' or 'mss',
we should assume that the "mod root directory" is the parent directory.
Therefore, go one directory up when translating paths.
Two reasons for this:
1. We have to take care when CLEO is trying to open a new custom script,
    it will try to do so from [chdir("CLEO")], so using an absolute path
    helps us avoid "undoing" it.
2. For some data files (like main.scm), the game does a [chdir("data")]
    ([chdir("data\scripts")] in San Andreas) and loads the file then.
    Using an absolute path, we don't need to care about this.
This makes Upstate Liberty fully loadable through ML
The destructor of Profiles was iterating through
the list in the middle of its clear() call.
This crashes consistently with VS2017.
@CookiePLMonster CookiePLMonster changed the title Various compatibility fixed for Upstate Liberty Various compatibility fixes for Upstate Liberty Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant