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: Built-in compiler gives a compilation error on a script that compiles with nwnsscomp.exe #106

Open Nereithr opened 4 months ago

Nereithr commented 4 months ago

First of all, this is a K1 script. K1 nwscript.nss was used to compile it. It compiles with both standalone nwnsscomp.exe (ripped from a deNCS install) and the TSLPatcher modified nwnsscomp.exe.

Attempting to compile k_ai_master.nss (with these source files) with the built-in compiler as-is (through holopatcher) results in an error:

[Error] [15:22:25] Function 'FinesseMeleeWeapons' has not been defined.

If the following two define lines are added to the beginning of k_inc_statfix.nss, the file compiles and the mod works:

void FinesseMeleeWeapons(int depth = 0, int IsHen = 0);
void RepeaterAttacks(int depth = 0, int IsHen = 0);

For what it's worth, nwnsscomp.exe compiles with those unnecessary defines as well.


I also encountered an extra compiler error earlier. Since I'm not using an IDE for .nss files, I had the following define included in the beginning of k_inc_statfix.nss so I could use NPP's autocomplete:

int CheckAppliedEffect(object oCreature, int EffectType, int EffectSubType = SUBTYPE_MAGICAL);

This is obviously not proper, since that function (which is part of k_inc_genutil) is included earlier in k_ai_master as part of

#include "k_inc_genutil"
#include "k_inc_statfix"

Despite this, nwnsscomp.exe compiled the file properly. Trying to compile with that define using the built-in compiler gives the following error:

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

I'm including the full holopatcher error logs for these as well as the source files (including the vanilla files necessary for compiling k_ai_master):

errorlog_finesse.txt errorlog_check.txt Source.zip

th3w1zard1 commented 4 months ago

FWIW this is still a bug in the betas of v1.6

th3w1zard1 commented 4 months ago

I am guessing it's a bug in the lexer.

Also:

also encountered an extra compiler error earlier. Since I'm not using an IDE for .nss files, I had the following define included in the beginning of k_inc_statfix.nss so I could use NPP's autocomplete:

int CheckAppliedEffect(object oCreature, int EffectType, int EffectSubType = SUBTYPE_MAGICAL);

This is obviously not proper, since that function (which is part of k_inc_genutil) is included earlier in k_ai_master as part of

include "k_inc_genutil"

include "k_inc_statfix"

I am under the impression the compiler does not even look at the #include directives, it considers all scripts that are in the folder. as part of the library_lookup: list[Path] argument passed to compile_nss.