Zum Inhalt wechseln

Foto

Advanced Script Compiler for NWN2 release thread


  • Bitte melde dich an um zu Antworten
116 Antworten in diesem Thema

#26
SkywingvL

SkywingvL
  • Members
  • 351 Beiträge
Posted release 9.

This includes a bug fix for the toolset compiler plugin only.

The bug, fixed in release 9, was that you could not get the dialog editor to populate the parameters for a conditional or action script unless you have compiled at least once script since opening the module. This was because the plugin was not initializing its resource management system until the first time a script was compiled, and this was causing the process to get the parameters for a script to fail until that happened.

#27
SkywingvL

SkywingvL
  • Members
  • 351 Beiträge
Release 10 posted. Direct download link (same as always): http://www.nynaeve.n...iptCompiler.zip

Release 10:
-----------

- A longstanding bug dating back to nwnnsscomp, where global variables that
were readonly and had initializers with assignments might be improperly
inlined if optimizations were enabled, has been fixed.

- The compiler can now optimize away dead sub-expressions in simple cases, such
as multiplication by zero or shift by 32 bits.

- The compiler can now optimize a multiply operation into a shift by power of
two.

- The compiler can now optimize addition by one and subtraction by one into a
decrement or increment operation.

- The compiler now issues a new warning, NSC6023, should function prototypes be
declared for the same function but with conflicting literal values for a
default value argument. It is legal for a prototype that does not set a
default value for an argument to follow a prototype that does set a default
value for an argument, but if a default value was set, it must match.

- A new pragma directive, #pragma pure_function(function-identifier), is now
supported. This pragma hints to the compiler that function-identifier, which
must be an already-declared function symbol, does not modify global state and
generates no side effects. This enables calls to the function to be elided
in certain circumstances, or for global variable initializer expressions that
invoke the function to be inlined in certain circumstances.

The programmer bears responsibility for ensuring that pure_function tagged
functions actually follow the rules for a pure function. Otherwise, program
behavior may be incorrect.

#28
Jeolf

Jeolf
  • Members
  • 2 Beiträge
Hi, I'm getting syntax errors whenever I try to compile something using a itemproperty variables.
Could you verify if it is working?

For instance:
NWNScriptCompiler.exe -1 -c x2_inc_itemprop.nss

NWNScriptCompiler - built Jan 21 2012 15:45:53
Copyright (C) 2008-2011 Skywing.
Portions copyright (C) 2003-2003, Edward T. Smith.
Portions copyright (C) 2003, The Open Knights Consortium.
Compiling: x2_inc_itemprop.NSS
x2_inc_itemprop.nss(80): Error: NSC1040: Syntax error at "itemproperty"
x2_inc_itemprop.nss(151): Error: NSC1040: Syntax error at "itemproperty"
x2_inc_itemprop.nss(157): Error: NSC1040: Syntax error at "itemproperty"
x2_inc_itemprop.nss(215): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(248): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(316): Error: NSC1040: Syntax error at "itemproperty"
x2_inc_itemprop.nss(620): Error: NSC1040: Syntax error at "ipTest"
x2_inc_itemprop.nss(804): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(837): Error: NSC1040: Syntax error at "itemproperty"
x2_inc_itemprop.nss(843): Error: NSC1040: Syntax error at "if"
x2_inc_itemprop.nss(854): Error: NSC1040: Syntax error at "if"
x2_inc_itemprop.nss(895): Error: NSC1040: Syntax error at "itemproperty"
x2_inc_itemprop.nss(1028): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(1057): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(1092): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(1314): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(1342): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(1364): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(1399): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(1427): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(1445): Error: NSC1040: Syntax error at "ip"
x2_inc_itemprop.nss(1507): Error: NSC1040: Syntax error at "ip"
Compilation aborted with errors.
Processing aborted.
Total Execution time = 17ms

Even just defining one like
itemproperty test;
will cause the compiler to claim there's a syntax error.

I'm using linux and wine to run it, but I don't think that should be a factor.
Any ideas about why it's complaining?

Bearbeitet von Jeolf, 02 Februar 2012 - 04:44 .


#29
SkywingvL

SkywingvL
  • Members
  • 351 Beiträge
Do you have a custom nwscript.nss (not recommended, but supported with the same limitations as the standard compiler) in the include path for the compiler? If so, please link it.

The definition for itemproperty comes from whichever nwscript.nss the compiler consumed. The standard nwscript.nss supplies a correct definition.

#30
Jeolf

Jeolf
  • Members
  • 2 Beiträge
*facepalm* That was it. I had apparently extracted the version included in NWN instead of HotU. Using the one from the expansion solved the problem.

Thanks a lot.

#31
eeriegeek

eeriegeek
  • Members
  • 47 Beiträge
I could swear I saw this discussed somewhere, but can't remember the answer. I recently exceeded the identifier limits, so I tried switching to the Advanced Script Compiler. I'm having trouble compiling code which includes CEP include files. The problem seems to be that some of the files have unterminated comment blocks. The compiler issues a warning - which is great, but also refuses to compile the enclosing script even with the v1.69 option.

../../NWNScriptCompiler.exe -1clev1.69 -r . -h ../.. ee_me_enter.nss
NWNScriptCompiler - built Jan 21 2012 15:45:53
Copyright (C) 2008-2011 Skywing.
Portions copyright (C) 2003-2003, Edward T. Smith.
Portions copyright (C) 2003, The Open Knights Consortium.
Loading base game resources...
Compiling: ee_me_enter.NSS
zep_inc_1st_rp.nss(2405): Warning: NSC6006: End of file reached while processing comment
ee_me_enter.nss is an include file, ignored.
Total Execution time = 1006ms

Short of dissassembling the CEP script HAKs to fix the offending code, is there a way to get around this?

#32
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1.799 Beiträge
Probably need to extract zep_inc_1st_rp.nss, and fix the comment, and place said file in override so it's used instead of the hak ( not sure on load order with that though ). Note that you don't really need script files in a hak - just makes players download those files which is only useful for SP, and those files will work based on how they were compiled. ( only NWN2 does the full recompile for parameters i think, and then only on conditional scripts like gui - conversations might also do that. )

Even if skywing could fix this, not sure what would happen by doing so, unless this comment is at the end of the file anyway. I think one of the flags allows you to choose how picky it is with this sort of thing, but i'll need to take a look at the available options and the read me later tonight to see. Not sure if that helps with your issue though.

Skywing, Need to edit -> Portions copyright © 2003-2003, Edward T. Smith. so it says Portions copyright © 2003, Edward T. Smith. as well, not that this affects anything.

#33
SkywingvL

SkywingvL
  • Members
  • 351 Beiträge
I'll fix the message next release.

This is a warning and not an error, so the script was still compiled. The warning means that there was an unterminated comment (e.g. a /* with no matching */ before the end of the file).

This is often a symptom of a bug but is just a warning because some of the inbox scripts that shipped with the game have this problem. You should still check the script in question to identify whether the warning was a symptom of a more serious problem or not, however.

#34
eeriegeek

eeriegeek
  • Members
  • 47 Beiträge
Skywing, I just noticed your message, thanks for looking at this. I didn't mean to imply that the warning regarding unterminated comment blocks was a bug. In fact I appreciate such messages regarding less than optimal coding practice.

The problem I'm having is the small message folllowing the warning: "ee_me_enter.nss is an include file, ignored." after which the file (which is certainly not an include file) in not compiled. This occurs for a fair number of my scripts with the ASC, which are otherwise built with the Bioware compiler. It seems almost like the unterminated comment block is not terminated at the end of the offending script file but perhaps carries over to the rest of the inclosing script, thus the inability to find the main function.

#35
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1.799 Beiträge
Can you post the respective code ( go ahead and find and extract it from the haks where it's coming from and post it on pastebin or dropbox, don't really touch much NWN1 scripts )

Often the devil is in the details, and it's hard to know the details from just a description of the problem. Be good if we could reproduce it in a less complex example which showcases the problem.

#36
eeriegeek

eeriegeek
  • Members
  • 47 Beiträge
Here's the simplest example I could make of what happens with ACS with an unterminated comment block in an include. Its short enough to post here :whistle:
Script: foo.nss
#include "foo_inc"
void main(){}
Include: foo_inc.nss
/*

Compile:
$ ../../NWNScriptCompiler -1clev1.69 -r . -h ../.. foo.nss
NWNScriptCompiler - built Jan 21 2012 15:45:53
Copyright (C) 2008-2011 Skywing.
Portions copyright (C) 2003-2003, Edward T. Smith.
Portions copyright (C) 2003, The Open Knights Consortium.
Loading base game resources...

Compiling: foo.NSS

foo_inc.nss(2): Warning: NSC6006: End of file reached while processing comment

foo.nss is an include file, ignored.

Total Execution time = 407ms
This is really only an issue with a released library (e.g. the CEP.) Hopefully we can get the CEP team to close the comments in the next release so it's not an issue. I will probably just remove the scripts from the hak and fix them locally.

#37
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1.799 Beiträge
reproduced with my variation of the compiler using your code
Meyer:~ brianmeyerdesign$ nwcompile "/Users/brianmeyerdesign/Desktop" "foo.nss";
NeverWinter Nights Script Compiler/Decompiler
Copyright 2002-2003, Edward T. Smith
Copyright 2003, The Open Knights Consortium

Copyright 2011, More Fixes from Skywing and Grinning Fool for NWN2

Compiling: foo.nss
foo_inc.nss(2): Warning: End of file reached while processing comment
File is an include file, ignored
Finished Compiling foo.nss

Basically it changes from
#include "foo_inc"
void main(){}
to
/*
void main(){}
when it includes the other file which just starts a comment.

Yeah the CEP team should do that.

Bearbeitet von painofdungeoneternal, 01 März 2012 - 05:16 .


#38
SkywingvL

SkywingvL
  • Members
  • 351 Beiträge
Thanks guys for the basic repro and additional information here.

I have made the following changes, which is queued for the next ASC release (hopefully soon):

- In compatibility mode (compiler version 1.69 or below specified, e.g. with -v1.69), the compiler will fix up an unterminated comment block at the end of an include by pretending as though it was closed. This is the behavior that the standard compiler provides. The warning about EOF while in a comment block is still emitted.

- If compiler version 1.70 or higher is specified, the current behavior is retained, i.e. we stop further parsing and issue the warning. If main hadn't been seen yet, then the script is considered an include only script.  While it could be argued that this is less than ideal versus allowing the comment to be terminated by a future stream, it's the longstanding nwnnsscomp behavior and users should really fix the bug (as highlighted by the warning) in 1.70+ mode.

This should address your scenario so long as you continue to use -v1.69 once I do a new ASC release. The best long term solution is still to fix the CEP scripts to not have this breakage.  Of course if you do move to -v1.70 mode (which generally turns off warnings about constructs that are incompatible with the standard compiler, e.g. because they exceed a standard compiler limitation), then you will have to fix the script.

As a temporary workaround until ASC release 11 is out the door, you could locally override the broken CEP hak include by defining a fixed version of that include locally.  I'll try and get the next ASC release out soon (I'll probably try to throw a few more pending changes in just to cut down on the amount of release overhead versus things actually changed in the release).

Bearbeitet von SkywingvL, 01 März 2012 - 08:05 .


#39
eeriegeek

eeriegeek
  • Members
  • 47 Beiträge
Thanks Skywing, I did pull the CEP scripts out and rebuild them. It turns out that there was only one include with the unterminated comment block. It just "included" its way into a number of places that made it look like more. The ACS also caught one additional potential bad construct, probably a typo that the orginal compiler missed ( object oPC = GetLocalObject(oPC,"FOO"); ), otherwise the scripts compiled fine. I've posted a note to the CEP forums and hopefully it will be easily fixed in the next release.

#40
SkywingvL

SkywingvL
  • Members
  • 351 Beiträge
A local workaround is to just place your own private copy of the include file (with the error fixed) in your module. That will override the hak in terms of the include copy in the hak.

The GetLocalObject() construct you mentioned would always expand to GetLocalObject(OBJECT_INVALID, ...). As such it would probably not produce the expected results (probably programmer error as you mentioned).

#41
RedRover72

RedRover72
  • Members
  • 16 Beiträge
n00b question... can this integrate into Visual Studio as a compiler?

#42
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1.799 Beiträge
Yes, it's a command line thing, so you'd integrate it similar to other tools which are command line. ( Most programming environments have this, i have done this with both xcode and bbedit on the mac )

Think there are a few who've tried it, but you probably could sort out how to set it up without too much effort.

#43
RedRover72

RedRover72
  • Members
  • 16 Beiträge
Meh, stupid cold medicine. I figured it out. I was a dummy. It helps if I actually tell it to compile the file I'm working on, duh.

Does anyone know of a simple front-end built for this, like what 2drunk did for NSSCLC? If not I'll see about whipping one up.

#44
SkywingvL

SkywingvL
  • Members
  • 351 Beiträge
RedRover72:

As it happens, I actually do have a Visual Studio 2010 propsheet collection that allows you to configure NWScript compiler settings from a property page in a Visual Studio project. That gives 'native' integration into the IDE (including settings inheritance and soforth), versus an external makefile integration that is more or less opaque to the IDE.

The NWN2 Datafile Accessor library distribution should include the propsheets you need. Alternatively, I've packaged it standalone here:

http://valera-ext.ny.../VSNWScript.zip

You'll want to set the path to the compiler (and if desired a default include path) in NWScript.props.

Bearbeitet von SkywingvL, 16 Mai 2012 - 05:54 .


#45
RedRover72

RedRover72
  • Members
  • 16 Beiträge
Fantastic. Thanks.

#46
SkywingvL

SkywingvL
  • Members
  • 351 Beiträge
You should also be able to use the propsheets to drive an MSBuild-based unattended (or command line based) build, if you want.

It is also certainly possible to create a conventional makefile based build system around the NWScript compiler.

If you're interested in more capabilities than standard NWScript offers, BTW, and you're writing code for a multiplayer PW (or other environment using nwn2server.exe), you might consider using the NWScript Accelerator plugin (check out the NWNX4 forum section at www.nwnx.org). That NWNX4 plugin allows you to write C# code that can interface natively with the nwscript.nss APIs, and which also can natively call .NET framework APIs.

#47
SkywingvL

SkywingvL
  • Members
  • 351 Beiträge
Release 12 posted. Direct download link (same as always):
http://www.nynaeve.n...iptCompiler.zip

Release 12:
-----------

- The pcode dump mode now works again for the standalone compiler.

- The compiler now allows compiled scripts to be up to 64MB, versus up to the
old limit of 512K. It is strongly recommended that scripts be kept under
512K compiled size for both compile-time and runtime performance reasons.

- The compiler now provides a proper compile time error (NSC1036) if a script
exceeded the maximum compiled script size. Previously, the compiler asserted
in this condition.

Release 11:
-----------

- In compatibility mode, the compiler will now terminate an unterminated
comment block at the end of an include file. This improves compatibility
with certain ill-formed third party scripts. In compiler version 1.70 or
higher, the fixup is not performed.

#48
kevL

kevL
  • Members
  • 4.052 Beiträge
using this is a Joy, i can hardly wait to compile more scripts!

:)

#49
Kanbyen

Kanbyen
  • Members
  • 11 Beiträge
Love this compiler update, thanks!

#50
John McA

John McA
  • Members
  • 11 Beiträge
Dear Skywing,

I'm so sorry but the readme documentation that comes with this download, with all the version updates, is way too advanced for me. I wanted to convert a few NWN2 .ncs script files to .nss or some kind of text format so that I can merge my spell changes with Kaedrin's to support both his pack and my custom module. I understand I might do this using the -d switch.

Unfortunately it seems like 20 years since I used anything like dos. Let's say I put the nwnscriptcompiler.exe in my ..program files.../nwn directory along with the single file I want to convert. Then I go to the cmd prompt in windows 7, where I can start typing. I can just about get to the directory and type nwnscriptcompiler -? to get another complicated list. Are you able to provide a complete idiot's instruction to the actual command to enter, or the whole process? Is it something like nwnscriptcompiler -d, then something that describes the directory and name of the single file I want to convert and then something that describes where the new file should go. Where best actually to put the exec file and the one I want to convert? (I only add this detail to show how much of an idiot I am but at least tried before asking for help!!)

Sorry again for such a basic question

John