NWNX4 - resurrected

I am glad to announce the NWNX4 project development has resumed, with new maintainers !

Currently only @scottmunday84 and me are working on NWNX4, but we would be happy to welcome new contributors !

You can contribute in a number of ways:

  • Open issues on GitHub, detailing bugs you encounters or asking for new features. We would love to get some feedback on the existing issues.
  • Improve the wiki pages to document how NWNX4 and its plugins works. Currently the wiki is almost empty.
  • Improve the NWScript files to provide new features or better documentation related to NWNX4 plugins.
  • Submit pull requests on GitHub to provide new features, plugins or fix bugs (require C++ knowledge). Don’t worry if your are not very experienced in C++, your PRs will be reviewed and you will receive help :wink:

Expect new features, plugins and improvements to come very soon :slightly_smiling_face:

Links

1 Like

Version v0.1.0 (first resurrected release)

This NWNX4 release brings the same features and interfaces as the official (now abandoned) version from nwnx4.org, and should be a drop-in replacement.

Under the hood, a lot of work has been done to update the codebase to be easily built with modern compilers and libraries, and CI pipelines have been setup to help newcomers submit pull requests.

On the plugin-side, this release comes with a lot more plugins than the official one:

  • xp_bugfix
  • xp_fastboot
  • xp_funcs *
  • xp_mysql and xp_sqlite
  • xp_objectattributes *
  • xp_pickpocket *
  • xp_profiler *
  • xp_srvadmin
  • xp_time

Some of these plugins (those marked with a *) may not be on-par with versions posted on the vault (maybe older, maybe newer). Please open an issue here if you find any difference.

Currently, only the MySQL plugin has gained new features:

  • Fixed the SQL object storage (The abandoned nwnx4 release had broken SCORCO functions).
  • Now uses the latest MariaDB client connector. This allows the plugin to connect to the SQL server using more secure authentication methods.
  • Added a charset option to correctly set the charset on connection (and re-connections), instead of sending SET NAMES utf8 queries.

Huge thanks to @SkywingvL and @scottmunday84 for helping me and supporting me to resurrect this important project ! - Crom

Version v0.2.0

NWNX changes

  • Fixed the gamespy watchdog not receiving ping responses on some configurations
  • Fixed the restart command not being executed correctly

Plugin changes

New plugin: xp_rpc !

xp_rpc is a plugin that allows high performance RPC communication between an NWN2 server and any set of microservices. A microservice can be built in any supported language of both gRPC and Protocol Buffers.
See the wiki for more information !

xp_bugfix

  • Fix a bug where the server crashed when BootPC cas called twice on the same PC
  • Fix a server crash when a character with more than 255 spells connects to the server
  • Fix a server crash when a player initiates a rest while in transition between two areas

xp_mysql / xp_sqlite

  • Added the function SQLGetLastInsertedID() to return the ID of the last inserted row

Huge thanks to all contributors ! :tada:

can x4 be hooked into single-player games? if not, any plans to make it so?

either way, good job :)

Currently there it’s not very practical to ship nwnx4 with custom modules, but it’s definitely something we want to do !

There are two issues that needs to be addressed in order to be able for players to unpack an archive and start nwnx4:

2 Likes

thanks for the info so far,

i would (hopefully will) look into it more, to ask better questions. Am not sure what the relation is between Nwn2 and NwNx4 …

Can it be considered a frontend for the nwn2 executable ?

It’s more a launcher for nwn2server.exe (not the game client nwn2main.exe).

NWNX4 starts the nwn2server process and inject a DLL (some custom code) into the nwn2server process, in order to apply some patches to the nwn2server executable during startup.
These patches are provided by NWNX4 plugins and do a lot of different things, like fixing game bugs, performance and stability (xp_bugfix), give access to SQL databases (xp_sqlite, xp_mysql), allow the modification of character files (xp_objectattributes), …

It’s probably not well known by solo module developers, but I bet all PW servers out there are already using NWNX4 (at least the old version)

1 Like

sounds like it shouldn’t be too difficult to adapt it to start nwn2main.exe

But then there’s a bit of a conflict with the ClientExtension …

and, am guessing it’d require some proficiency with a disassember to get at game-code that one might want to alter the behavior of … ?

 
eg. Currently the game doesn’t respect “auto-fail on a roll of 1” for two of the 3 savetypes … /iirc

The DLL injection and patching rely on some static addresses in memory, and I would expect those addresses to be very different for nwn2main.exe.

The two are complementary. The ClientExtension improves player experience with nwn2main.exe and NWNX4 extends the capabilities and stability of nwn2server.

Yes, and to be honest this is beyond my skills… some smart people already found some useful pointers and created plugins with them. I only updated their code to build on modern compilers.

1 Like

ah… yeh :\

ok

i see. A guy could learn it but it’d take a while to get the skillz up.

 
 
Thanks Crom, my understanding of X4 leveled up ;)

Version v1.0.0

/!\ Breaking changes

New file tree

The location of plugin files have been modified in order to ease the process of upgrading nwnx4 and its plugins.

tl;dr: Move all your xp_*.dll files into the plugins/ folder before upgrading nwnx4, and you should be fine for this part.

Here’s how the new file tree works:

  • config.example\: Contains config templates for nwnx4 and its official plugins. On first installation, you must copy those config files into the root nwnx4 directory. Files under config.example\ will be updated with nwnx4, and you will need to compare them with your copies in order to support new features when nwnx4 will be updated in the future.
  • nwn2server-dll\: Contains all DLL files that the NWN2Server process will need (you don’t need to copy them into the nwn2 installation dir anymore). This directory is automatically added to the DLL search path for the NWN2Server process, so you can add your own DLL files to it this folder. Note that this folder is not searched by the .NET runtime, so it will not work with xp_AuroraServerNWScript DLLs.
  • nwscript\: Contains the include scripts to copy to your module (nothing changed here).
  • plugins\: Contains all nwnx4 plugin DLL files. By default, nwnx4 will search this directory when loading plugins (see “Plugins loading” below). In order to install additional plugins, you will need to copy their DLL files into this folder.

Note that .ini and .txt (logs) files are still stored in the nwnx4 root directory. This is on purpose, to be consistent with unofficial plugins that expect their config and log files to be located here. Only the plugin DLL files have been moved to a separate directory.

Plugins loading

The way plugins are loaded has been modified in order to explicitly chose which plugins must be loaded. This makes upgrading easier and prevents conflicts between some plugins like xp_mysql and xp_sqlite.

nwnx.ini now has the plugin_list option:

# List of all plugins to load when starting the NWN2Server process
# The list is comma-separated, and each element must be either:
# - A plugin name without the path extension. The associated DLL file must be
#   located inside the plugins/ folder of nwnx4.
# - A plugin full path like 'C:\Program File\plugins\xp_yourplugin.dll' or
#   'dev_plugins\xp_yourplugin.dll'.
#   Relative paths must be relative to the nwnx4 directory.
#
# default: load all plugins in the nwnx4 folder (legacy behavior, not recommended)
plugin_list = xp_bugfix, xp_sqlite, xp_funcs, xp_time, xp_srvadmin, xp_rpc, xp_objectattributes

By default if you don’t update your nwnx.ini file, nwnx will load all plugins inside the plugins/ folder. This is not recommended and will cause issues if you don’t manually remove plugins you don’t want to load, like xp_mysql / xp_sqlite.

New features

Packaging nwnx4 with your module

You can now assemble a package containing nwnx4 and your custom content and module(s), that players can quickly extract to start a NWN2 server and connect to it. The main idea is to enhance single-player experience by providing server-grade features, like game logic fixes, SQL storage, advanced scripting, …

See the “How to: Distribute nwnx4 with your module” section of README.md

The following features have been implemented for supporting packages:

xp_pickpocket

xp_pickpocket was crashing the server when somebody tried to pickpocket somebody. This is no longer the case thanks to @ap5d !

xp_sqlite

Now supports SCORCO functions (store and retrieve objects) !
While SQLite is slower and less reliable than MySQL, it is very practical for making nwnx4 + module packages because it does not require to install any additional software.

Huge thanks to all contributors ! :tada:

3 Likes

v1.0.1

This release fixes a bug where xp_ServerExts (not shipped with nwnx4) was unable to use some functions provided by xp_bugfix, causing error messages like Failed to resolve symbol SetPacketFilterCallouts. .

This bug affects all plugins that requires xp_bugfix to be installed (and now it is fixed).

2 Likes