NickHugi / PyKotor

A Python library that can read and modify most file formats used by the game Knights of the Old Republic and its sequel.
GNU Lesser General Public License v3.0
11 stars 3 forks source link

HoloPatcher 1.5.2: Issues/differences from TSLPatcher when compiling scripts and using namespaces #105

Open Nereithr opened 3 months ago

Nereithr commented 3 months ago

First of all, I'm not sure if this is a HoloPatcher issue, user issue or simply a difference in implementation that probably needs to be documented.

I'm testing this with a mod edits k_ai_master.nss and adds 2 new includes. The mod works when compiled manually as well as when compiled using TSLPatcher. TSLPatcher recommends putting nwnnsscomp.exe and nwscript.nss in tslpatchdata (using nwnsscomp included with TSLPatcher and a KOTOR 1 nwscript from the Steam version). For setups without namespaces, all other files go here as well. For setups with namespaces, all source files (except nwscript.nss) go into the namespace folder (if a separate namespace folder is chosen). This is slightly rambly and step-by-step, so a more concise TLDR is at the end.

The relevant section of changes.ini in all cases is:

[CompileList]
Replace0=k_ai_master.nss

The first difference/issue I ran into is when I'm NOT using namespaces

This is how tslpatchdata looks ![image](https://github.com/NickHugi/PyKotor/assets/72263884/3a84daf6-3823-4c9f-910b-8d36ff94589f)

When running the install, everything compiles and works properly, but nwscript.nss is additionally moved into Override.

nwsscript.nss snippet from installer ![image](https://github.com/NickHugi/PyKotor/assets/72263884/135e9004-7281-4970-8b55-646d08a65313)

Now, with namespaces (all of the relevant files are now in the "base" folder).

tslpatchdata setup that works for TSLPatcher ![image](https://github.com/NickHugi/PyKotor/assets/72263884/bbf3cfeb-0aa8-4e7d-9724-c4a2f2c789b7)

Attempting to install with holopatcher will now use built-in compilers and return a compilation error:

[Error] [17:15:59] Function 'CheckAppliedEffect' already has a prototype or been defined.

Attempting to remove the unnecessary define returns a different compilation error.

Moving both nwnnsscomp.exe and nwscript.nss into the folder with changes.ini resolves the issue, but nwscript.nss is now moved to Override yet again.


TLDR:

  1. The installer copies nwscript.nss into Override. This is probably undesirable behaviour;
  2. HoloPatcher looks for nwnsscomp.exe and nwscript.nss within the same directory as the changes.ini for a given namespace. This could either be fixed to work like TSLPatcher or (even better) just documented on the wiki in the HoloPatcher changes section.
  3. Builtin compiler works differently from nwnsscomp.exe, at least with KOTOR 1 scripts. The fact that it even exists should probably be mentioned on the wiki.

Additionally, would you even recommend distributing mods as source nss files to begin with or is it better to just precompile them and include the source separately?

th3w1zard1 commented 3 months ago

We ran into each other in one of the kotor discords, since this was discussed I'll publicly post the information here as well.

The installer copies nwscript.nss into Override. This is probably undesirable behaviour;

At the time of introducing nwscript.nss being moved into Override, I was using the KTool version which requires it. It turns out there are actually 4 known versions of nwnnsscomp.exe, which have since been documented here nwscript.nss is required for KScript, V1, and KTool's versions.

The installer moving nwscript.nss is left in as an attempt to unify all 4 versions and abstract away the burden of determining if they are using the correct version. You can prevent nwscript.nss from being moved by simply taking the file out of your tslpatchdata namespace. Eventually we will implement a check for which nwnnsscomp.exe version the user is using and only move that script if they are using the non-tslpatcher version.

TSLPatcher recommends putting nwnnsscomp.exe and nwscript.nss in tslpatchdata (using nwnsscomp included with TSLPatcher and a KOTOR 1 nwscript from the Steam version). For setups without namespaces, all other files go here as well. For setups with namespaces, all source files (except nwscript.nss) go into the namespace folder (if a separate namespace folder is chosen). This is slightly rambly and step-by-step, so a more concise TLDR is at the end.

HoloPatcher looks for nwnsscomp.exe and nwscript.nss within the same directory as the changes.ini for a given namespace. This could either be fixed to work like TSLPatcher or (even better) just documented on the wiki in the HoloPatcher changes section.

This was recently discovered behavior and is currently fixed on master and will be in the next beta5 version of v1.6. Seems we forgot consider namespaces when looking up nwnnsscomp.exe

Builtin compiler works differently from nwnsscomp.exe, at least with KOTOR 1 scripts. The fact that it even exists should probably be mentioned on the wiki.

Absolutely agree, will update some point soon.