C# Class ALFA.SystemInfo

This class encapsulates general system information about the game environment and configuration.
Show file Open project: ALandFarAway/ALFA-Base-Resources Class Usage Examples

Public Methods

Method Description
AdjustGameDifficultyLevel ( bool IncreaseDifficulty ) : void

Adjust the difficulty level of the game.

DisableWer ( ) : void

Disable error reporting for the current process.

EnableWer ( ) : void

Enable error reporting for the current process.

GetCentralVaultPath ( ) : string

Get the filesystem path to the central, shared vault. Note that the server must be using the server vault plugin for this function to work.

GetCentralVaultPathForAccount ( string AccountName ) : string

Get the remote server vault path for an account, given an account name. Note that the server must be using the server vault plugin for this function to work.

GetFirstDynamicObjectId ( CLRScriptBase Script ) : uint

Get the first object id corresponding to dynamic objects. All object ids below this object id are static objects (excluding PC objects).

GetGameInstallationDirectory ( ) : string

This method gets the directory where the game is installed. The path has a trailing path separator.

GetGameObjUpdateTime ( CLRScriptBase Script ) : int

This function gets the current GameObjUpdate interval.

GetHakDirectory ( ) : string

This routine gets the home directory hak directory for the current NWN2Server instance.

GetHomeDirectory ( ) : string

This routine gets the NWN2 "Home" directory, which is the directory name by -home on the command line, or else the user's NWN2 directory under Documents.

GetModuleDirectory ( ) : string

This routine gets the directory with the module data files for the current module. The routine only works if the server was started with -moduledir.

GetModuleResourceName ( ) : string

This routine gets the resource name of the module that was passed on the server command line. Note that if the server did not have a module argument then null is returned.

GetNWNX4IniString ( string IniFileName, string SectionName, string SettingName, string DefaultValue ) : string

Read an INI file setting from a NWNX4 plugin INI. The INI must follow the Windows INI format of [Sections] with Setting=Value . Note that some plugins, such as xp_mysql, do NOT use this format and cannot use this function. The maximum string length read from the INI file by this function is MAX_PATH.

GetNWNX4IniString ( string IniFileName, string SectionName, string SettingName, string DefaultValue, int MaxValueSize ) : string

Read an INI file setting from a NWNX4 plugin INI. The INI must follow the Windows INI format of [Sections] with Setting=Value . Note that some plugins, such as xp_mysql, do NOT use this format and cannot use this function.

GetNWNX4InstallationDirectory ( ) : string

This method gets the directory where NWNX4 is installed. The path has a trailing path separator.

GetOverrideDirectory ( ) : string

This routine gets the override directory for the current NWN2Server instance.

GetSQLConnectionSettings ( ) : SQLConnectionSettings

Get the database connection settings from the SQL plugin, e.g. for use in setting up an auxiliary database connection. Throws an exception if the settings could not be found.

GetServerUdpListener ( CLRScriptBase Script ) : IPEndPoint

This routine determines the UDP listener endpoint for the server.

GetServerVaultPathForAccount ( string AccountName ) : string

Get the local server vault path for an account, given an account name. Note that the server must be using the server vault plugin for this function to work.

GetVaultStoragePluginInUse ( ) : bool

Check whether the storage plugin for xp_ServerVault is in use, implying that the central vault path is just a cache that can be purged for purge cached character requests.

IsDynamicObject ( CLRScriptBase Script, uint ObjectId ) : bool

Check whether an object is a dynamic object, i.e. one created after module startup.

IsRunningInNWN2Server ( ) : bool

Check whether the caller is running in the context of the game server process.

IsSafeFileName ( string FileName, bool AllowSeparators = false ) : bool

Check whether a file name has dangerous characters, such as path characters or references to special device names.

LoadAssemblyFromNWNX4 ( string AssemblyName ) : Assembly

This helper method loads an assembly from the NWNX4 installation directory.

SafeDeleteFile ( string FileName ) : void

Delete a file while ignoring any exceptions that may occur.

SetAdminPassword ( CLRScriptBase Script, string Password ) : void

Change the admin password.

SetDMPassword ( CLRScriptBase Script, string Password ) : void

Change the DM password.

SetGameObjUpdateTime ( CLRScriptBase Script, int GameObjUpdateTime ) : void

This function sets the GameObjUpdate interval. The default is 200 milliseconds.

SetPlayerPassword ( CLRScriptBase Script, string Password ) : void

Change the player password.

ShutdownGameServer ( CLRScriptBase Script ) : void

Request that the game server cleanly shut down. Note that NWNX4 will restart the game server afterwards in the default ALFA configuration, so this function is usually used to restart the game server, not stop it permanently.

Private Methods

Method Description
FindWindowEx ( IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow ) : IntPtr
GetDlgItem ( IntPtr hDlg, int nIDDlgItem ) : IntPtr
GetExoAppDifficultySliderWindow ( IntPtr ExoAppWindow ) : IntPtr

Get the difficulty slider window from an Exo App window.

GetExoAppWindow ( ) : IntPtr

Get the Exo main app window.

GetExtendedUdpTable ( IntPtr pUdpTable, UInt32 &pdwSize, Int32 bOrder, UInt32 ulAf, UDP_TABLE_CLASS TableClass, UInt32 Reserved ) : UInt32
GetPrivateProfileStringW ( string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, UInt32 nSize, string lpFileName ) : UInt32
GetScrollInfo ( IntPtr hwnd, int fnBar, [ lpsi ) : bool
GetWindowThreadProcessId ( IntPtr hwnd, uint &lpdwProcessId ) : uint
SendMessage ( IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam ) : IntPtr
SetScrollInfo ( IntPtr hwnd, int fnBar, [ lpsi, bool fRedraw ) : int
WerAddExcludedApplication ( string pwszExeName, int bAllUsers ) : UInt32
WerRemoveExcludedApplication ( string pwszExeName, int bAllUsers ) : UInt32

Method Details

AdjustGameDifficultyLevel() public static method

Adjust the difficulty level of the game.
public static AdjustGameDifficultyLevel ( bool IncreaseDifficulty ) : void
IncreaseDifficulty bool Supplies true to increase /// difficulty, else false to reduce it. Nothing happens if the game /// is already at the highest difficulty and an attempt to increase it, /// or vice versa, is made.
return void

DisableWer() public static method

Disable error reporting for the current process.
public static DisableWer ( ) : void
return void

EnableWer() public static method

Enable error reporting for the current process.
public static EnableWer ( ) : void
return void

GetCentralVaultPath() public static method

Get the filesystem path to the central, shared vault. Note that the server must be using the server vault plugin for this function to work.
public static GetCentralVaultPath ( ) : string
return string

GetCentralVaultPathForAccount() public static method

Get the remote server vault path for an account, given an account name. Note that the server must be using the server vault plugin for this function to work.
public static GetCentralVaultPathForAccount ( string AccountName ) : string
AccountName string
return string

GetFirstDynamicObjectId() public static method

Get the first object id corresponding to dynamic objects. All object ids below this object id are static objects (excluding PC objects).
public static GetFirstDynamicObjectId ( CLRScriptBase Script ) : uint
Script CLRScriptFramework.CLRScriptBase Supplies the caller's script object.
return uint

GetGameInstallationDirectory() public static method

This method gets the directory where the game is installed. The path has a trailing path separator.
public static GetGameInstallationDirectory ( ) : string
return string

GetGameObjUpdateTime() public static method

This function gets the current GameObjUpdate interval.
public static GetGameObjUpdateTime ( CLRScriptBase Script ) : int
Script CLRScriptFramework.CLRScriptBase Supplies the caller's script object.
return int

GetHakDirectory() public static method

This routine gets the home directory hak directory for the current NWN2Server instance.
public static GetHakDirectory ( ) : string
return string

GetHomeDirectory() public static method

This routine gets the NWN2 "Home" directory, which is the directory name by -home on the command line, or else the user's NWN2 directory under Documents.
public static GetHomeDirectory ( ) : string
return string

GetModuleDirectory() public static method

This routine gets the directory with the module data files for the current module. The routine only works if the server was started with -moduledir.
public static GetModuleDirectory ( ) : string
return string

GetModuleResourceName() public static method

This routine gets the resource name of the module that was passed on the server command line. Note that if the server did not have a module argument then null is returned.
public static GetModuleResourceName ( ) : string
return string

GetNWNX4IniString() public static method

Read an INI file setting from a NWNX4 plugin INI. The INI must follow the Windows INI format of [Sections] with Setting=Value . Note that some plugins, such as xp_mysql, do NOT use this format and cannot use this function. The maximum string length read from the INI file by this function is MAX_PATH.
public static GetNWNX4IniString ( string IniFileName, string SectionName, string SettingName, string DefaultValue ) : string
IniFileName string Supplies the INI file name, such as /// "AuroraServerVault.ini". The file name should not include a path /// component.
SectionName string Supplies the section name, such as /// "Settings".
SettingName string Supplies the setting name, such as /// "LocalServerVaultPath".
DefaultValue string Supplies the default value to return if /// the setting didn't exist.
return string

GetNWNX4IniString() public static method

Read an INI file setting from a NWNX4 plugin INI. The INI must follow the Windows INI format of [Sections] with Setting=Value . Note that some plugins, such as xp_mysql, do NOT use this format and cannot use this function.
public static GetNWNX4IniString ( string IniFileName, string SectionName, string SettingName, string DefaultValue, int MaxValueSize ) : string
IniFileName string Supplies the INI file name, such as /// "AuroraServerVault.ini". The file name should not include a path /// component.
SectionName string Supplies the section name, such as /// "Settings".
SettingName string Supplies the setting name, such as /// "LocalServerVaultPath".
DefaultValue string Supplies the default value to return if /// the setting didn't exist.
MaxValueSize int Supplies the maximum length of the /// string value to read from the INI file. This must be at least as /// long as the DefaultValue length.
return string

GetNWNX4InstallationDirectory() public static method

This method gets the directory where NWNX4 is installed. The path has a trailing path separator.
public static GetNWNX4InstallationDirectory ( ) : string
return string

GetOverrideDirectory() public static method

This routine gets the override directory for the current NWN2Server instance.
public static GetOverrideDirectory ( ) : string
return string

GetSQLConnectionSettings() public static method

Get the database connection settings from the SQL plugin, e.g. for use in setting up an auxiliary database connection. Throws an exception if the settings could not be found.
public static GetSQLConnectionSettings ( ) : SQLConnectionSettings
return SQLConnectionSettings

GetServerUdpListener() public static method

This routine determines the UDP listener endpoint for the server.
public static GetServerUdpListener ( CLRScriptBase Script ) : IPEndPoint
Script CLRScriptFramework.CLRScriptBase Supplies the caller's script object.
return System.Net.IPEndPoint

GetServerVaultPathForAccount() public static method

Get the local server vault path for an account, given an account name. Note that the server must be using the server vault plugin for this function to work.
public static GetServerVaultPathForAccount ( string AccountName ) : string
AccountName string
return string

GetVaultStoragePluginInUse() public static method

Check whether the storage plugin for xp_ServerVault is in use, implying that the central vault path is just a cache that can be purged for purge cached character requests.
public static GetVaultStoragePluginInUse ( ) : bool
return bool

IsDynamicObject() public static method

Check whether an object is a dynamic object, i.e. one created after module startup.
public static IsDynamicObject ( CLRScriptBase Script, uint ObjectId ) : bool
Script CLRScriptFramework.CLRScriptBase Supplies the caller's script object.
ObjectId uint Supplies the object id to check.
return bool

IsRunningInNWN2Server() public static method

Check whether the caller is running in the context of the game server process.
public static IsRunningInNWN2Server ( ) : bool
return bool

IsSafeFileName() public static method

Check whether a file name has dangerous characters, such as path characters or references to special device names.
public static IsSafeFileName ( string FileName, bool AllowSeparators = false ) : bool
FileName string Supplies the file name to check.
AllowSeparators bool Supplies true if separators are /// allowed.
return bool

LoadAssemblyFromNWNX4() public static method

This helper method loads an assembly from the NWNX4 installation directory.
public static LoadAssemblyFromNWNX4 ( string AssemblyName ) : Assembly
AssemblyName string Supplies the DLL file name of the /// assembly to load. The assembly should be present in the NWNX4 /// installation directory.
return System.Reflection.Assembly

SafeDeleteFile() public static method

Delete a file while ignoring any exceptions that may occur.
public static SafeDeleteFile ( string FileName ) : void
FileName string Supplies the name of the file to /// delete.
return void

SetAdminPassword() public static method

Change the admin password.
public static SetAdminPassword ( CLRScriptBase Script, string Password ) : void
Script CLRScriptFramework.CLRScriptBase Supplies the caller's script object.
Password string Supplies the new password to set.
return void

SetDMPassword() public static method

Change the DM password.
public static SetDMPassword ( CLRScriptBase Script, string Password ) : void
Script CLRScriptFramework.CLRScriptBase Supplies the caller's script object.
Password string Supplies the new password to set.
return void

SetGameObjUpdateTime() public static method

This function sets the GameObjUpdate interval. The default is 200 milliseconds.
public static SetGameObjUpdateTime ( CLRScriptBase Script, int GameObjUpdateTime ) : void
Script CLRScriptFramework.CLRScriptBase Supplies the caller's script object.
GameObjUpdateTime int Supplies the new game object update /// time, in milliseconds.
return void

SetPlayerPassword() public static method

Change the player password.
public static SetPlayerPassword ( CLRScriptBase Script, string Password ) : void
Script CLRScriptFramework.CLRScriptBase Supplies the caller's script object.
Password string Supplies the new password to set.
return void

ShutdownGameServer() public static method

Request that the game server cleanly shut down. Note that NWNX4 will restart the game server afterwards in the default ALFA configuration, so this function is usually used to restart the game server, not stop it permanently.
public static ShutdownGameServer ( CLRScriptBase Script ) : void
Script CLRScriptFramework.CLRScriptBase Supplies the caller's script object.
return void